OPAL  Version 3.18.8
pcss.h
Go to the documentation of this file.
1 /*
2  * pcss.h
3  *
4  * PC Sound System support.
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (c) 2001 Equivalence Pty. Ltd.
10  *
11  * The contents of this file are subject to the Mozilla Public License
12  * Version 1.0 (the "License"); you may not use this file except in
13  * compliance with the License. You may obtain a copy of the License at
14  * http://www.mozilla.org/MPL/
15  *
16  * Software distributed under the License is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18  * the License for the specific language governing rights and limitations
19  * under the License.
20  *
21  * The Original Code is Open Phone Abstraction Library.
22  *
23  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24  *
25  * Contributor(s): ______________________________________.
26  */
27 
28 #ifndef OPAL_OPAL_PCSS_H
29 #define OPAL_OPAL_PCSS_H
30 
31 #ifdef P_USE_PRAGMA
32 #pragma interface
33 #endif
34 
35 
36 #include <opal_config.h>
37 
38 #if OPAL_HAS_PCSS
39 
40 #include <ptlib/sound.h>
41 #include <ep/localep.h>
42 
43 
44 class OpalPCSSConnection;
45 
46 #define OPAL_PCSS_PREFIX "pc"
47 
48 
52 {
54  public:
60  OpalManager & manager,
61  const char * prefix = OPAL_PCSS_PREFIX
62  );
63 
68 
100  virtual PSafePtr<OpalConnection> MakeConnection(
101  OpalCall & call,
102  const PString & party,
103  void * userData = NULL,
104  unsigned options = 0,
105  OpalConnection::StringOptions * stringOptions = NULL
106  );
108 
116  virtual bool OnOutgoingCall(
117  const OpalLocalConnection & connection
118  );
119 
129  virtual bool OnIncomingCall(
130  OpalLocalConnection & connection
131  );
132 
138  virtual bool OnUserInput(
139  const OpalLocalConnection & connection,
140  const PString & indication
141  );
142 
143 #if OPAL_VIDEO
144 
146  virtual bool CreateVideoInputDevice(
147  const OpalConnection & connection,
148  const OpalMediaFormat & mediaFormat,
149  PVideoInputDevice * & device,
150  bool & autoDelete
151  );
152 #endif
153 
154 
161  OpalCall & call,
162  const PString & playDevice,
163  const PString & recordDevice,
164  void * userData,
165  unsigned options,
166  OpalConnection::StringOptions * stringOptions
167  );
168 
171  virtual PSoundChannel * CreateSoundChannel(
172  const OpalPCSSConnection & connection,
173  const OpalMediaFormat & mediaFormat,
174  unsigned sessionID,
175  bool isSource
176  );
177 
180  virtual PSoundChannel * CreateSoundChannel(
181  const OpalPCSSConnection & connection,
182  const OpalMediaFormat & mediaFormat,
183  unsigned sessionID,
184  bool isSource,
185  const PString & device
186  );
188 
197  PSafePtr<OpalPCSSConnection> GetPCSSConnectionWithLock(
198  const PString & token,
199  PSafetyMode mode = PSafeReadWrite
200  ) { return GetConnectionWithLockAs<OpalPCSSConnection>(token, mode); }
201 
210  virtual PBoolean OnShowIncoming(
211  const OpalPCSSConnection & connection
212  );
213 
218  virtual PBoolean AcceptIncomingConnection(
219  const PString & connectionToken
220  );
221 
226  virtual PBoolean RejectIncomingConnection(
227  const PString & connectionToken,
228  const OpalConnection::CallEndReason & reason = OpalConnection::EndedByAnswerDenied
229  );
230 
236  virtual PBoolean OnShowOutgoing(
237  const OpalPCSSConnection & connection
238  );
239 
245  virtual PBoolean OnShowUserInput(
246  const OpalPCSSConnection & connection,
247  const PString & indication
248  );
250 
262  const PString & tone
263  );
264 
268  const PString & GetLocalRingbackTone() const { return m_localRingbackTone; }
269 
277  virtual PBoolean SetSoundChannelPlayDevice(const PString & name);
278 
283  const PString & GetSoundChannelPlayDevice() const { return m_soundChannelPlayDevice; }
284 
292  virtual PBoolean SetSoundChannelRecordDevice(const PString & name);
293 
298  const PString & GetSoundChannelRecordDevice() const { return m_soundChannelRecordDevice; }
299 
306  virtual bool SetSoundChannelOnHoldDevice(const PString & name);
307 
311  const PString & GetSoundChannelOnHoldDevice() const { return m_soundChannelOnHoldDevice; }
312 
317  virtual bool SetSoundChannelOnRingDevice(const PString & name);
318 
322  const PString & GetSoundChannelOnRingDevice() const { return m_soundChannelOnRingDevice; }
323 
324 #if OPAL_VIDEO
325 
327  virtual bool SetVideoGrabberDevice(const PVideoDevice::OpenArgs & args);
328 
331  const PVideoDevice::OpenArgs & GetVideoGrabberDevice() const { return GetManager().GetVideoInputDevice(); }
332 
335  virtual bool SetVideoPreviewDevice(const PVideoDevice::OpenArgs & args);
336 
339  const PVideoDevice::OpenArgs & GetVideoPreviewDevice() const { return GetManager().GetVideoPreviewDevice(); }
340 
343  virtual bool SetVideoDisplayDevice(const PVideoDevice::OpenArgs & args);
344 
347  const PVideoDevice::OpenArgs & GetVideoDisplayDevice() const { return GetManager().GetVideoOutputDevice(); }
348 
352  virtual bool SetVideoOnHoldDevice(const PVideoDevice::OpenArgs & args);
353 
357  const PVideoDevice::OpenArgs & GetVideoOnHoldDevice() const { return m_videoOnHoldDevice; }
358 
362  virtual bool SetVideoOnRingDevice(const PVideoDevice::OpenArgs & args);
363 
367  const PVideoDevice::OpenArgs & GetVideoOnRingDevice() const { return m_videoOnRingDevice; }
368 #endif
369 
375 
381  unsigned depth
382  );
383 
389 
395  unsigned depth
396  );
398 
399  protected:
407 #if OPAL_VIDEO
408  PVideoDevice::OpenArgs m_videoOnHoldDevice;
409  PVideoDevice::OpenArgs m_videoOnRingDevice;
410 #endif
411 
412  private:
413  P_REMOVE_VIRTUAL(OpalPCSSConnection *, CreateConnection(OpalCall &, const PString &, const PString &, void *), 0)
414  P_REMOVE_VIRTUAL(PSoundChannel *,CreateSoundChannel(const OpalPCSSConnection&,const OpalMediaFormat&,PBoolean),NULL);
415  P_REMOVE_VIRTUAL(PSoundChannel *,CreateSoundChannel(const OpalPCSSConnection&,const OpalMediaFormat&,const PString&,bool),NULL);
416 };
417 
418 
421 class OpalPCSSConnection : public OpalLocalConnection
422 {
423  PCLASSINFO(OpalPCSSConnection, OpalLocalConnection);
424  public:
429  OpalPCSSConnection(
430  OpalCall & call,
431  OpalPCSSEndPoint & endpoint,
432  const PString & playDevice,
433  const PString & recordDevice,
434  unsigned options = 0,
435  OpalConnection::StringOptions * stringOptions = NULL
436  );
437 
440  ~OpalPCSSConnection();
442 
462  virtual void OnReleased();
463 
465  virtual void OnApplyStringOptions();
466 
477  virtual PBoolean SetAlerting(
478  const PString & calleeName,
479  PBoolean withMedia
480  );
481 
488  virtual bool TransferConnection(
489  const PString & remoteParty
490  );
491 
496  virtual void OnHold(
497  bool fromRemote,
498  bool onHold
499  );
500 
515  virtual OpalMediaStream * CreateMediaStream(
516  const OpalMediaFormat & mediaFormat,
517  unsigned sessionID,
518  PBoolean isSource
519  );
520 
525  virtual void OnStartMediaPatch(
526  OpalMediaPatch & patch
527  );
528 
532  virtual PBoolean SetAudioVolume(
533  PBoolean source,
534  unsigned percentage
535  );
536 
540  virtual PBoolean GetAudioVolume(
541  PBoolean source,
542  unsigned & percentage
543  );
544 
547  virtual bool SetAudioMute(
548  bool source,
549  bool mute
550  );
551 
554  virtual bool GetAudioMute(
555  bool source,
556  bool & mute
557  );
558 
562  virtual unsigned GetAudioSignalLevel(
563  PBoolean source
564  );
565 
570  virtual void AlertingIncoming(
571  bool withMedia = false
572  );
573 
576  virtual void AcceptIncoming();
578 
583  virtual PSoundChannel * CreateSoundChannel(
584  const OpalMediaFormat & mediaFormat,
585  unsigned sessionID,
586  bool isSource
587  );
588 
591  virtual bool ChangeSoundChannel(
592  const PString & device,
593  bool isSource,
594  unsigned sessionID = 0
595  );
596  virtual bool ChangeSoundChannel(
597  const PString & device,
598  OpalAudioMediaStream * stream
599  );
600 
605  bool StartReadUserInput(
606  PChannel * channel,
607  bool autoDelete = true
608  );
609 
613  void StopReadUserInput();
615 
621  const PString & GetLocalRingbackTone() const { return m_localRingbackTone; }
622 
627  const PString & GetSoundChannelPlayDevice() const { return m_soundChannelPlayDevice; }
628 
633  const PString & GetSoundChannelRecordDevice() const { return m_soundChannelRecordDevice; }
634 
638  const PString & GetSoundChannelOnHoldDevice() const { return m_soundChannelOnHoldDevice; }
639 
643  const PString & GetSoundChannelOnRingDevice() const { return m_soundChannelOnRingDevice; }
644 
645 #if OPAL_VIDEO
646 
649  const PVideoDevice::OpenArgs & GetVideoOnHoldDevice() const { return m_videoOnHoldDevice; }
650 
654  const PVideoDevice::OpenArgs & GetVideoOnRingDevice() const { return m_videoOnRingDevice; }
655 #endif
656 
662 
669 
670 
671  protected:
680 #if OPAL_VIDEO
681  PVideoDevice::OpenArgs m_videoOnHoldDevice;
682  PVideoDevice::OpenArgs m_videoOnRingDevice;
683 #endif
684 
685  PThread * m_ringbackThread;
686  PSyncPoint m_ringbackStop;
687  void RingbackMain();
688 
689  PThread * m_userInputThread;
690  PChannel * m_userInputChannel;
692  void UserInputMain();
693 
694  P_REMOVE_VIRTUAL(PSoundChannel *,CreateSoundChannel(const OpalMediaFormat&,PBoolean),NULL);
695 };
696 
697 #else
698 
699 #define OPAL_PCSS_PREFIX
700 
701 #endif // OPAL_HAS_PCSS
702 
703 #endif // OPAL_OPAL_PCSS_H
PThread * m_ringbackThread
Definition: pcss.h:685
PVideoDevice::OpenArgs m_videoOnRingDevice
Definition: pcss.h:682
Definition: manager.h:150
unsigned m_soundChannelBuffers
Definition: pcss.h:678
virtual PBoolean SetSoundChannelRecordDevice(const PString &name)
virtual bool CreateVideoInputDevice(const OpalConnection &connection, const OpalMediaFormat &mediaFormat, PVideoInputDevice *&device, bool &autoDelete)
unsigned m_soundChannelBufferTime
Definition: pcss.h:406
bool m_userInputAutoDelete
Definition: pcss.h:691
PString m_soundChannelOnRingDevice
Definition: pcss.h:404
PVideoDevice::OpenArgs m_videoOnHoldDevice
Definition: pcss.h:408
unsigned m_soundChannelBufferTime
Definition: pcss.h:679
const PVideoDevice::OpenArgs & GetVideoInputDevice(OpalVideoFormat::ContentRole role=OpalVideoFormat::eNoRole) const
Definition: manager.h:1866
virtual PSoundChannel * CreateSoundChannel(const OpalPCSSConnection &connection, const OpalMediaFormat &mediaFormat, unsigned sessionID, bool isSource)
void SetSoundChannelBufferTime(unsigned depth)
const PString & GetSoundChannelRecordDevice() const
Definition: pcss.h:633
const PVideoDevice::OpenArgs & GetVideoOutputDevice(OpalVideoFormat::ContentRole role=OpalVideoFormat::eNoRole) const
Definition: manager.h:1904
virtual bool SetVideoDisplayDevice(const PVideoDevice::OpenArgs &args)
Definition: localep.h:469
virtual bool SetVideoPreviewDevice(const PVideoDevice::OpenArgs &args)
OpalPCSSEndPoint & m_endpoint
Definition: pcss.h:672
virtual bool OnOutgoingCall(const OpalLocalConnection &connection)
PSyncPoint m_ringbackStop
Definition: pcss.h:686
unsigned GetSoundChannelBufferTime() const
Definition: pcss.h:388
virtual bool OnIncomingCall(OpalLocalConnection &connection)
const PVideoDevice::OpenArgs & GetVideoOnRingDevice() const
Definition: pcss.h:654
PString m_soundChannelOnRingDevice
Definition: pcss.h:677
const PString & GetSoundChannelOnHoldDevice() const
Definition: pcss.h:638
virtual PBoolean RejectIncomingConnection(const PString &connectionToken, const OpalConnection::CallEndReason &reason=OpalConnection::EndedByAnswerDenied)
virtual PBoolean OnShowIncoming(const OpalPCSSConnection &connection)
const PString & GetSoundChannelRecordDevice() const
Definition: pcss.h:298
virtual OpalPCSSConnection * CreateConnection(OpalCall &call, const PString &playDevice, const PString &recordDevice, void *userData, unsigned options, OpalConnection::StringOptions *stringOptions)
PString m_localRingbackTone
Definition: pcss.h:400
virtual bool SetSoundChannelOnRingDevice(const PString &name)
const PVideoDevice::OpenArgs & GetVideoOnHoldDevice() const
Definition: pcss.h:649
const PVideoDevice::OpenArgs & GetVideoOnHoldDevice() const
Definition: pcss.h:357
bool SetLocalRingbackTone(const PString &tone)
const PString & GetSoundChannelOnHoldDevice() const
Definition: pcss.h:311
OpalPCSSEndPoint(OpalManager &manager, const char *prefix=OPAL_PCSS_PREFIX)
const PString & GetLocalRingbackTone() const
Definition: pcss.h:268
virtual PBoolean OnShowOutgoing(const OpalPCSSConnection &connection)
Definition: connection.h:530
const PVideoDevice::OpenArgs & GetVideoPreviewDevice(OpalVideoFormat::ContentRole role=OpalVideoFormat::eNoRole) const
Definition: manager.h:1885
virtual void OnHold(OpalConnection &connection, bool fromRemote, bool onHold)
#define OPAL_PCSS_PREFIX
Definition: pcss.h:46
Definition: localep.h:63
PString m_localRingbackTone
Definition: pcss.h:673
Definition: patch.h:56
unsigned GetSoundChannelBufferDepth() const
Definition: pcss.h:661
Definition: mediafmt.h:806
Definition: pcss.h:421
PSafePtr< OpalPCSSConnection > GetPCSSConnectionWithLock(const PString &token, PSafetyMode mode=PSafeReadWrite)
Definition: pcss.h:197
const PVideoDevice::OpenArgs & GetVideoOnRingDevice() const
Definition: pcss.h:367
PString m_soundChannelRecordDevice
Definition: pcss.h:675
void SetSoundChannelBufferDepth(unsigned depth)
unsigned m_soundChannelBuffers
Definition: pcss.h:405
Definition: call.h:62
Definition: pcss.h:51
const PString & GetSoundChannelOnRingDevice() const
Definition: pcss.h:322
const PVideoDevice::OpenArgs & GetVideoDisplayDevice() const
Definition: pcss.h:347
PString m_soundChannelOnHoldDevice
Definition: pcss.h:676
const PVideoDevice::OpenArgs & GetVideoPreviewDevice() const
Definition: pcss.h:339
PVideoDevice::OpenArgs m_videoOnHoldDevice
Definition: pcss.h:681
virtual void OnReleased(OpalConnection &connection)
OpalManager & GetManager() const
Definition: endpoint.h:839
virtual PBoolean AcceptIncomingConnection(const PString &connectionToken)
PChannel * m_userInputChannel
Definition: pcss.h:690
PThread * m_userInputThread
Definition: pcss.h:689
const PString & GetSoundChannelOnRingDevice() const
Definition: pcss.h:643
virtual PBoolean OnShowUserInput(const OpalPCSSConnection &connection, const PString &indication)
virtual bool SetVideoGrabberDevice(const PVideoDevice::OpenArgs &args)
PVideoDevice::OpenArgs m_videoOnRingDevice
Definition: pcss.h:409
Definition: connection.h:462
PString m_soundChannelRecordDevice
Definition: pcss.h:402
const PString & GetSoundChannelPlayDevice() const
Definition: pcss.h:283
virtual PBoolean SetSoundChannelPlayDevice(const PString &name)
virtual bool SetVideoOnRingDevice(const PVideoDevice::OpenArgs &args)
Definition: mediastrm.h:110
PString m_soundChannelOnHoldDevice
Definition: pcss.h:403
unsigned GetSoundChannelBufferDepth() const
Definition: pcss.h:374
PString m_soundChannelPlayDevice
Definition: pcss.h:674
Definition: connection.h:415
const PString & GetLocalRingbackTone() const
Definition: pcss.h:621
const PString & GetSoundChannelPlayDevice() const
Definition: pcss.h:627
PString m_soundChannelPlayDevice
Definition: pcss.h:401
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned options=0, OpalConnection::StringOptions *stringOptions=NULL)
unsigned GetSoundChannelBufferTime() const
Definition: pcss.h:667
const PVideoDevice::OpenArgs & GetVideoGrabberDevice() const
Definition: pcss.h:331
virtual bool SetSoundChannelOnHoldDevice(const PString &name)
virtual bool SetVideoOnHoldDevice(const PVideoDevice::OpenArgs &args)
virtual bool OnUserInput(const OpalLocalConnection &connection, const PString &indication)