4 * H.281 protocol handler implementation for the OpenH323 Project.
6 * Copyright (c) 2006-2007 Network for Educational Technology, ETH Zurich.
7 * Written by Hannes Friederich.
9 * The contents of this file are subject to the Mozilla Public License
10 * Version 1.0 (the "License"); you may not use this file except in
11 * compliance with the License. You may obtain a copy of the License at
12 * http://www.mozilla.org/MPL/
14 * Software distributed under the License is distributed on an "AS IS"
15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16 * the License for the specific language governing rights and limitations
19 * Contributor(s): ______________________________________.
22 * Revision 1.4 2007/08/05 22:34:08 hfriederich
23 * Merge from MediaTypeBranch.
26 * - Session ID replaced by OpalMediaType class
27 * - Dynamic session ID assignment in H.323 according to H.245
28 * - Attempt to dynamically handle different media types (audio / video /
29 * / fax / H.224 etc) instead of hardcoded in the core classes.
31 * - Improved propagation of media formats / options between connections
32 * - New media command implementation, uses chain-like propagation
33 * - SDP 'Capabilities' to ease handling of complex SDP parameters
35 * - New SIP Transaction handling, avoiding race conditions
36 * - Re-written H.224 implementation as an example how to add additional
37 * media types without adding code to the base classes
38 * (connection / endpoint / manager etc)
40 * This commit breaks the following code:
41 * - T38Fax implementation.
42 * - Recently added FMTP handling in MediaFormat/Option and SDP.
44 * Revision 1.3 2007/04/19 06:17:20 csoutheren
45 * Fixes for precompiled headers with gcc
47 * Revision 1.2 2006/04/23 18:52:19 dsandras
48 * Removed warnings when compiling with gcc on Linux.
50 * Revision 1.1 2006/04/20 16:48:17 hfriederich
51 * Initial version of H.224/H.281 implementation.
55 #ifndef __OPAL_H281HANDLER_H
56 #define __OPAL_H281HANDLER_H
66 #include <h224/h224handler.h>
67 #include <h224/h281.h>
69 class OpalH224Handler
;
71 /** This class implements a storage for which cameras are
72 available at both the local or remote side
74 class H281VideoSource
: public PObject
76 PCLASSINFO(H281VideoSource
, PObject
);
83 BOOL
IsEnabled() const { return isEnabled
; }
84 void SetEnabled(BOOL flag
) { isEnabled
= flag
; }
86 BYTE
GetVideoSourceNumber() const { return (firstOctet
>> 4) & 0x0f; }
87 void SetVideoSourceNumber(BYTE number
);
89 BOOL
CanMotionVideo() const { return (firstOctet
>> 2) & 0x01; }
90 void SetCanMotionVideo(BOOL flag
);
92 BOOL
CanNormalResolutionStillImage() const { return (firstOctet
>> 1) & 0x01; }
93 void SetCanNormalResolutionStillImage(BOOL flag
);
95 BOOL
CanDoubleResolutionStillImage() const { return (firstOctet
& 0x01); }
96 void SetCanDoubleResolutionStillImage(BOOL flag
);
98 BOOL
CanPan() const { return (secondOctet
>> 7) & 0x01; }
99 void SetCanPan(BOOL flag
);
101 BOOL
CanTilt() const { return (secondOctet
>> 6) & 0x01; }
102 void SetCanTilt(BOOL flag
);
104 BOOL
CanZoom() const { return (secondOctet
>> 5) & 0x01; }
105 void SetCanZoom(BOOL flag
);
107 BOOL
CanFocus() const { return (secondOctet
>> 4) & 0x01; }
108 void SetCanFocus(BOOL flag
);
110 void Encode(BYTE
*data
) const;
111 BOOL
Decode(const BYTE
*data
);
121 /** This class implements a defalt H.281 handler
123 class OpalH281Handler
: public OpalH224Client
125 PCLASSINFO(OpalH281Handler
, OpalH224Client
);
133 CurrentVideoSource
= 0x00,
135 AuxiliaryCamera
= 0x02,
136 DocumentCamera
= 0x03,
137 AuxiliaryDocumentCamera
= 0x04,
138 VideoPlaybackSource
= 0x05
141 /**Overriding default OpalH224Client methods */
142 virtual BYTE
GetClientID() const { return H281_CLIENT_ID
; };
143 virtual BOOL
HasExtraCapabilities() const { return TRUE
; };
145 /**Processing incoming frames. Overrides from OpalH224Client */
146 virtual void OnReceivedExtraCapabilities(const BYTE
*capabilities
, PINDEX size
);
147 virtual void OnReceivedMessage(const H224_Frame
& message
);
149 BYTE
GetLocalNumberOfPresets() const { return localNumberOfPresets
; }
150 void SetLocalNumberOfPresets(BYTE presets
) { localNumberOfPresets
= presets
; }
152 BYTE
GetRemoteNumberOfPresets() const { return remoteNumberOfPresets
; }
154 H281VideoSource
& GetLocalVideoSource(VideoSource source
);
155 H281VideoSource
& GetRemoteVideoSource(VideoSource source
);
157 /** Causes the H.281 handler to start the desired action
158 The action will continue until StopAction() is called.
160 void StartAction(H281_Frame::PanDirection panDirection
,
161 H281_Frame::TiltDirection tiltDirection
,
162 H281_Frame::ZoomDirection zoomDireciton
,
163 H281_Frame::FocusDirection focusDirection
);
165 /** Stops any action currently ongoing
169 /** Tells the remote side to select the desired video source using the
170 mode specified. Does nothing if either video source or mode aren't
173 void SelectVideoSource(BYTE videoSourceNumber
, H281_Frame::VideoMode videoMode
);
175 /** Tells the remote side to store the current camera settings as a preset
176 with the preset number given
178 void StoreAsPreset(BYTE presetNumber
);
180 /** Tells the remote side to activate the given preset
182 void ActivatePreset(BYTE presetNumber
);
184 /** Causes the H.281 handler to send its capabilities.
185 Capabilities include the number of available cameras, (default one)
186 the camera abilities (default none) and the number of presets that
187 can be stored (default zero)
189 void SendExtraCapabilities() const;
192 * methods that subclasses can override.
193 * The default handler does not implement FECC on the local side.
194 * Thus, the default behaviour is to do nothing.
197 /** Called each time a remote endpoint sends its capability list
199 virtual void OnRemoteCapabilitiesUpdated();
201 /** Indicates to start the action specified
203 virtual void OnStartAction(H281_Frame::PanDirection panDirection
,
204 H281_Frame::TiltDirection tiltDirection
,
205 H281_Frame::ZoomDirection zoomDirection
,
206 H281_Frame::FocusDirection focusDirection
);
208 /** Indicates to stop the action stared with OnStartAction()
210 virtual void OnStopAction();
212 /** Indicates to select the desired video source
214 virtual void OnSelectVideoSource(BYTE videoSourceNumber
, H281_Frame::VideoMode videoMode
);
216 /** Indicates to store the current camera settings as a preset
218 virtual void OnStoreAsPreset(BYTE presetNumber
);
220 /** Indicates to activate the given preset number
222 virtual void OnActivatePreset(BYTE presetNumber
);
226 PDECLARE_NOTIFIER(PTimer
, OpalH281Handler
, ContinueAction
);
227 PDECLARE_NOTIFIER(PTimer
, OpalH281Handler
, StopActionLocally
);
229 BYTE localNumberOfPresets
;
230 BYTE remoteNumberOfPresets
;
231 H281VideoSource localVideoSources
[6];
232 H281VideoSource remoteVideoSources
[6];
234 H281_Frame transmitFrame
;
235 PTimer transmitTimer
;
237 H281_Frame::PanDirection requestedPanDirection
;
238 H281_Frame::TiltDirection requestedTiltDirection
;
239 H281_Frame::ZoomDirection requestedZoomDirection
;
240 H281_Frame::FocusDirection requestedFocusDirection
;
244 #endif // __OPAL_H281HANDLER_H