OPAL  Version 3.14.3
h281handler.h
Go to the documentation of this file.
1 /*
2  * h281handler.h
3  *
4  * H.281 protocol handler implementation for the OpenH323 Project.
5  *
6  * Copyright (c) 2006 Network for Educational Technology, ETH Zurich.
7  * Written by Hannes Friederich.
8  *
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/
13  *
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
17  * under the License.
18  *
19  * Contributor(s): ______________________________________.
20  *
21  * $Revision: 32531 $
22  * $Author: rjongbloed $
23  * $Date: 2014-08-15 14:46:03 +1000 (Fri, 15 Aug 2014) $
24  */
25 
26 #ifndef OPAL_H224_H281HANDLER_H
27 #define OPAL_H224_H281HANDLER_H
28 
29 #ifdef P_USE_PRAGMA
30 #pragma interface
31 #endif
32 
33 #ifndef _PTLIB_H
34 #include <ptlib.h>
35 #endif
36 
37 #include <opal_config.h>
38 
39 #if OPAL_HAS_H281
40 
41 #include <h224/h224handler.h>
42 #include <h224/h281.h>
43 
44 class OpalH224Handler;
45 
49 {
50  PCLASSINFO(OpalH281Client, OpalH224Client);
51  public:
54 
55  P_DECLARE_ENUM(VideoSourceIds,
56  CurrentVideoSource,
57  MainCameraId,
58  AuxiliaryCameraId,
59  DocumentCameraId,
60  AuxiliaryDocumentCameraId,
61  VideoPlaybackSourceId,
62  UserDefinedSourceId1,
63  UserDefinedSourceId2,
64  UserDefinedSourceId3,
65  UserDefinedSourceId4,
66  UserDefinedSourceId5,
67  UserDefinedSourceId6,
68  UserDefinedSourceId7,
69  UserDefinedSourceId8,
70  UserDefinedSourceId9,
71  UserDefinedSourceId10
72  );
73 
74  // Predefined source names
75  static const PConstString & MainCamera();
76  static const PConstString & AuxiliaryCamera();
77  static const PConstString & DocumentCamera();
78  static const PConstString & AuxiliaryDocumentCamera();
79  static const PConstString & VideoPlayback();
80 
82  virtual BYTE GetClientID() const { return OpalH224Client::H281ClientID; }
83  virtual bool HasExtraCapabilities() const { return true; }
84 
86  virtual void OnReceivedExtraCapabilities(const BYTE *capabilities, PINDEX size);
87  virtual void OnReceivedMessage(const H224_Frame & message);
88 
89  // Presets
90  unsigned GetLocalNumberOfPresets() const { return m_localNumberOfPresets; }
91  void SetLocalNumberOfPresets(unsigned presets) { m_localNumberOfPresets = presets; }
92 
94 
99  bool Action(PVideoControlInfo::Types type, int direction, const PTimeInterval & duration);
100 
105  bool SelectVideoSource(
106  const PString & source,
108  );
109 
113  void StoreAsPreset(BYTE presetNumber);
114 
117  void ActivatePreset(BYTE presetNumber);
118 
124  void SendExtraCapabilities() const;
125 
126  /*
127  * methods that subclasses can override.
128  * The default handler does not implement FECC on the local side.
129  * Thus, the default behaviour is to do nothing.
130  */
131 
134  virtual void OnRemoteCapabilitiesChanged();
135 
138  virtual void OnStartAction(int directions[PVideoControlInfo::NumTypes]) = 0;
139 
142  virtual void OnStopAction() = 0;
143 
146  virtual void OnSelectVideoSource(const PString & source, H281_Frame::VideoMode videoMode);
147 
150  virtual void OnStoreAsPreset(BYTE presetNumber);
151 
154  virtual void OnActivatePreset(BYTE presetNumber);
155 
158  void SetCapabilityChangedNotifier(const PNotifier & notifier);
159 
165  void SetOnActionNotifier(const PNotifier & notifier);
166 
167  struct Capability
168  {
169  Capability();
170  PINDEX Encode(VideoSourceIds sourceId, BYTE * capabilities, PINDEX offset) const;
171  PINDEX Decode(VideoSourceIds sourceId, const BYTE * capabilities, PINDEX offset);
172 
173  PString m_name;
175 
177  {
178  // First four are from PVideoControlInfo::Types
179  MotionVideo = PVideoControlInfo::NumTypes,
183  };
185 
186 #if PTRACING
187  friend ostream & operator<<(ostream & strm, const Capability & cap);
188 #endif
189  };
190 
194  VideoSourceIds sourceId,
195  const Capability & capability
196  ) { m_localCapability[sourceId == CurrentVideoSource ? m_localSourceId : sourceId] = capability; }
197 
201  VideoSourceIds sourceId
202  ) const { return m_remoteCapability[sourceId == CurrentVideoSource ? m_remoteSourceId : sourceId]; }
203 
204  protected:
205  PDECLARE_NOTIFIER(PTimer, OpalH281Client, ContinueAction);
206  PDECLARE_NOTIFIER(PTimer, OpalH281Client, StopAction);
207  PDECLARE_NOTIFIER(PTimer, OpalH281Client, ReceiveActionTimeout);
208  void SendStopAction();
209 
210  PMutex m_mutex;
211 
213  PNotifier m_onAction;
214 
215  VideoSourceIds m_localSourceId;
216  Capability m_localCapability[NumVideoSourceIds];
219 
220  VideoSourceIds m_remoteSourceId;
221  Capability m_remoteCapability[NumVideoSourceIds];
223 
226  PTimer m_stopTimer;
227 };
228 
229 
233 {
235  public:
237 
239  void Attach(
240  PVideoInputDevice * device,
241  const PString & source = MainCamera()
242  );
243  void Detach(
244  PVideoInputDevice * device
245  );
246  bool SelectVideoDevice(
247  PVideoInputDevice * device,
249  );
250 
251  virtual void OnStartAction(int directions[PVideoControlInfo::NumTypes]);
252  virtual void OnStopAction();
253 
254  protected:
255  PDECLARE_NOTIFIER(PTimer, OpalFarEndCameraControl, StepCamera);
256 
257  PTimeInterval m_stepRate;
258  PVideoInputDevice * m_videoInputDevices[NumVideoSourceIds];
259  int m_step[PVideoControlInfo::NumTypes];
260  PTimer m_stepTimer;
261 };
262 
263 
264 #endif // OPAL_HAS_H281
265 
266 #endif // OPAL_H224_H281HANDLER_H