lidep.h
Go to the documentation of this file.
/*
* lidep.h
*
* Line Interface Device EndPoint
*
* Open Phone Abstraction Library
*
* Copyright (c) 2001 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open H323 Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions of this code were written with the assisance of funding from
* Quicknet Technologies, Inc. http://www.quicknet.net.
*
* Contributor(s): ______________________________________.
*
* $Revision: 27149 $
* $Author: rjongbloed $
* $Date: 2012-03-07 18:32:36 -0600 (Wed, 07 Mar 2012) $
*/
#ifndef OPAL_LIDS_LIDEP_H
#define OPAL_LIDS_LIDEP_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <opal/buildopts.h>
#include <opal/endpoint.h>
#include <lids/lid.h>
#include <codec/silencedetect.h>
class OpalLineConnection;
class OpalLineEndPoint : public OpalEndPoint
{
PCLASSINFO(OpalLineEndPoint, OpalEndPoint);
public:
OpalLineEndPoint(
OpalManager & manager
);
~OpalLineEndPoint();
virtual PSafePtr<OpalConnection> MakeConnection(
OpalCall & call,
const PString & party,
void * userData = NULL,
unsigned int options = 0,
OpalConnection::StringOptions * stringOptions = NULL
);
virtual OpalMediaFormatList GetMediaFormats() const;
virtual OpalLineConnection * CreateConnection(
OpalCall & call,
OpalLine & line,
void * userData,
const PString & number
);
PSafePtr<OpalLineConnection> GetLIDConnectionWithLock(
const PString & token,
PSafetyMode mode = PSafeReadWrite
) { return PSafePtrCast<OpalConnection, OpalLineConnection>(GetConnectionWithLock(token, mode)); }
PBoolean AddLine(
OpalLine * line
);
void RemoveLine(
OpalLine * line
);
const PList<OpalLine> & GetLines() const { return lines;};
void RemoveLine(
const PString & token
);
void RemoveAllLines();
virtual PBoolean AddLinesFromDevice(
OpalLineInterfaceDevice & device
);
void RemoveLinesFromDevice(
OpalLineInterfaceDevice & device
);
PBoolean AddDeviceNames(
const PStringArray & descriptors
);
PBoolean AddDeviceName(
const PString & descriptor
);
const OpalLineInterfaceDevice * GetDeviceByName(
const PString & descriptor
);
virtual PBoolean AddDevice(
OpalLineInterfaceDevice * device
);
void RemoveDevice(
OpalLineInterfaceDevice * device
);
void RemoveDevices() { RemoveAllLines(); }
OpalLine * GetLine(
const PString & lineName,
bool enableAudio = false,
bool terminating = true
);
void SetDefaultLine(
const PString & lineName
);
bool SetCountryCode(
OpalLineInterfaceDevice::T35CountryCodes country
);
bool SetCountryCodeName(
const PString & countryName
);
protected:
PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines);
virtual void MonitorLine(OpalLine & line);
OpalLIDList devices;
OpalLineList lines;
PString defaultLine;
PMutex linesMutex;
PThread * monitorThread;
PSyncPoint exitFlag;
};
class OpalLineConnection : public OpalConnection
{
PCLASSINFO(OpalLineConnection, OpalConnection);
public:
OpalLineConnection(
OpalCall & call,
OpalLineEndPoint & endpoint,
OpalLine & line,
const PString & number
);
virtual PString GetPrefixName() const;
virtual bool IsNetworkConnection() const { return !line.IsTerminal(); }
virtual PBoolean SetUpConnection();
virtual PBoolean SetAlerting(
const PString & calleeName,
PBoolean withMedia
);
virtual PBoolean SetConnected();
virtual void OnReleased();
virtual PString GetDestinationAddress();
virtual OpalMediaFormatList GetMediaFormats() const;
virtual OpalMediaStream * CreateMediaStream(
const OpalMediaFormat & mediaFormat,
unsigned sessionID,
PBoolean isSource
);
virtual PBoolean OnOpenMediaStream(
OpalMediaStream & stream
);
virtual void OnClosedMediaStream(
const OpalMediaStream & stream
);
virtual PBoolean SetAudioVolume(
PBoolean source,
unsigned percentage
);
virtual unsigned GetAudioSignalLevel(
PBoolean source
);
virtual PBoolean SendUserInputString(
const PString & value
);
virtual PBoolean SendUserInputTone(
char tone,
int duration
);
virtual PBoolean PromptUserInput(
PBoolean play
);
void StartIncoming();
virtual void Monitor();
OpalLine & GetLine() { return line; }
OpalLineInterfaceDevice::CallProgressTones GetPromptTone() const { return m_promptTone; }
void SetPromptTone(OpalLineInterfaceDevice::CallProgressTones tone) { m_promptTone = tone; }
void setDialDelay(
unsigned int uiDialDelay
) { m_dialParams.m_dialStartDelay = uiDialDelay;}
unsigned int getDialDelay() const { return m_dialParams.m_dialStartDelay; }
protected:
OpalLineEndPoint & endpoint;
OpalLine & line;
bool wasOffHook;
unsigned minimumRingCount;
OpalLineInterfaceDevice::DialParams m_dialParams;
OpalLineInterfaceDevice::CallProgressTones m_promptTone;
PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming);
PThread * handlerThread;
};
class OpalLineMediaStream : public OpalMediaStream
{
PCLASSINFO(OpalLineMediaStream, OpalMediaStream);
public:
OpalLineMediaStream(
OpalLineConnection & conn,
const OpalMediaFormat & mediaFormat,
unsigned sessionID,
PBoolean isSource,
OpalLine & line
);
~OpalLineMediaStream();
virtual PBoolean Open();
virtual PBoolean ReadPacket(
RTP_DataFrame & packet
);
virtual PBoolean WritePacket(
RTP_DataFrame & packet
);
virtual PBoolean ReadData(
BYTE * data,
PINDEX size,
PINDEX & length
);
virtual PBoolean WriteData(
const BYTE * data,
PINDEX length,
PINDEX & written
);
virtual PBoolean SetDataSize(
PINDEX dataSize,
PINDEX frameTime
);
virtual PBoolean IsSynchronous() const;
virtual PBoolean RequiresPatchThread(
OpalMediaStream * stream
) const;
OpalLine & GetLine() { return line; }
protected:
virtual void InternalClose();
OpalLine & line;
bool notUsingRTP;
bool useDeblocking;
unsigned missedCount;
BYTE lastSID[4];
bool lastFrameWasSignal;
unsigned directLineNumber;
};
class OpalLineSilenceDetector : public OpalSilenceDetector
{
PCLASSINFO(OpalLineSilenceDetector, OpalSilenceDetector);
public:
OpalLineSilenceDetector(
OpalLine & line,
const Params & newParam
);
virtual unsigned GetAverageSignalLevel(
const BYTE * buffer,
PINDEX size
);
protected:
OpalLine & line;
};
#endif // OPAL_LIDS_LIDEP_H
// End of File ///////////////////////////////////////////////////////////////
OpalSilenceDetector::Params
Definition: silencedetect.h:54
OpalLineMediaStream::~OpalLineMediaStream
~OpalLineMediaStream()
OpalManager
Definition: manager.h:74
OpalLineEndPoint::PDECLARE_NOTIFIER
PDECLARE_NOTIFIER(PThread, OpalLineEndPoint, MonitorLines)
OpalEndPoint
Definition: endpoint.h:67
OpalLineEndPoint::GetLine
OpalLine * GetLine(const PString &lineName, bool enableAudio=false, bool terminating=true)
OpalLineMediaStream::lastFrameWasSignal
bool lastFrameWasSignal
Definition: lidep.h:665
OpalMediaStream::isSource
bool isSource
Definition: mediastrm.h:421
OpalLineEndPoint::AddDevice
virtual PBoolean AddDevice(OpalLineInterfaceDevice *device)
OpalLineInterfaceDevice::T35CountryCodes
T35CountryCodes
Definition: lid.h:747
OpalLineConnection::GetAudioSignalLevel
virtual unsigned GetAudioSignalLevel(PBoolean source)
OpalLineEndPoint::GetLines
const PList< OpalLine > & GetLines() const
Definition: lidep.h:167
OpalLineMediaStream::IsSynchronous
virtual PBoolean IsSynchronous() const
OpalLineEndPoint::CreateConnection
virtual OpalLineConnection * CreateConnection(OpalCall &call, OpalLine &line, void *userData, const PString &number)
buildopts.h
OpalLineMediaStream::line
OpalLine & line
Definition: lidep.h:660
OpalLineMediaStream::useDeblocking
bool useDeblocking
Definition: lidep.h:662
OpalLineEndPoint::GetDeviceByName
const OpalLineInterfaceDevice * GetDeviceByName(const PString &descriptor)
OpalLineConnection::StartIncoming
void StartIncoming()
OpalLineConnection::SendUserInputString
virtual PBoolean SendUserInputString(const PString &value)
OpalLineConnection::PromptUserInput
virtual PBoolean PromptUserInput(PBoolean play)
OpalLineConnection::Monitor
virtual void Monitor()
lid.h
OpalLineConnection::SetUpConnection
virtual PBoolean SetUpConnection()
OpalLineConnection::GetPrefixName
virtual PString GetPrefixName() const
OpalLineMediaStream::lastSID
BYTE lastSID[4]
Definition: lidep.h:664
OpalLineConnection::OpalLineConnection
OpalLineConnection(OpalCall &call, OpalLineEndPoint &endpoint, OpalLine &line, const PString &number)
OpalLineConnection::OnOpenMediaStream
virtual PBoolean OnOpenMediaStream(OpalMediaStream &stream)
OpalLineConnection
Definition: lidep.h:308
OpalLineConnection::IsNetworkConnection
virtual bool IsNetworkConnection() const
Definition: lidep.h:339
OpalLineConnection::GetDestinationAddress
virtual PString GetDestinationAddress()
OpalLineConnection::SetAudioVolume
virtual PBoolean SetAudioVolume(PBoolean source, unsigned percentage)
OpalLineEndPoint::AddDeviceNames
PBoolean AddDeviceNames(const PStringArray &descriptors)
OpalLineSilenceDetector::OpalLineSilenceDetector
OpalLineSilenceDetector(OpalLine &line, const Params &newParam)
OpalLineMediaStream::WriteData
virtual PBoolean WriteData(const BYTE *data, PINDEX length, PINDEX &written)
OpalLineConnection::OnReleased
virtual void OnReleased()
OpalLineEndPoint::RemoveDevice
void RemoveDevice(OpalLineInterfaceDevice *device)
OpalLineEndPoint::~OpalLineEndPoint
~OpalLineEndPoint()
Make sure thread has stopped before exiting.
OpalLineEndPoint::SetCountryCodeName
bool SetCountryCodeName(const PString &countryName)
OpalSilenceDetector
Definition: silencedetect.h:43
OpalLineConnection::m_dialParams
OpalLineInterfaceDevice::DialParams m_dialParams
Definition: lidep.h:544
OpalLineConnection::SetPromptTone
void SetPromptTone(OpalLineInterfaceDevice::CallProgressTones tone)
Definition: lidep.h:525
OpalLineConnection::CreateMediaStream
virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
OpalMediaFormatList
Definition: mediafmt.h:72
OpalLineEndPoint::exitFlag
PSyncPoint exitFlag
Definition: lidep.h:302
OpalLineConnection::GetMediaFormats
virtual OpalMediaFormatList GetMediaFormats() const
OpalConnection::StringOptions
Definition: connection.h:462
OpalLineSilenceDetector::GetAverageSignalLevel
virtual unsigned GetAverageSignalLevel(const BYTE *buffer, PINDEX size)
OpalLineEndPoint::SetCountryCode
bool SetCountryCode(OpalLineInterfaceDevice::T35CountryCodes country)
OpalMediaStream::sessionID
unsigned sessionID
Definition: mediastrm.h:417
OpalLineEndPoint::RemoveLine
void RemoveLine(OpalLine *line)
OpalLineConnection::setDialDelay
void setDialDelay(unsigned int uiDialDelay)
Definition: lidep.h:529
RTP_DataFrame
Definition: rtp.h:71
OpalLineEndPoint
Definition: lidep.h:55
OpalLineMediaStream::WritePacket
virtual PBoolean WritePacket(RTP_DataFrame &packet)
OpalLineConnection::wasOffHook
bool wasOffHook
Definition: lidep.h:542
OpalLineMediaStream::SetDataSize
virtual PBoolean SetDataSize(PINDEX dataSize, PINDEX frameTime)
OpalMediaFormat
Definition: mediafmt.h:724
OpalLineConnection::GetPromptTone
OpalLineInterfaceDevice::CallProgressTones GetPromptTone() const
Definition: lidep.h:521
OpalLineConnection::SetAlerting
virtual PBoolean SetAlerting(const PString &calleeName, PBoolean withMedia)
OpalLineEndPoint::RemoveLinesFromDevice
void RemoveLinesFromDevice(OpalLineInterfaceDevice &device)
silencedetect.h
OpalCall
Definition: call.h:65
OpalLineConnection::line
OpalLine & line
Definition: lidep.h:541
OpalLineEndPoint::monitorThread
PThread * monitorThread
Definition: lidep.h:301
OpalLineEndPoint::AddLine
PBoolean AddLine(OpalLine *line)
OpalLineEndPoint::AddDeviceName
PBoolean AddDeviceName(const PString &descriptor)
OpalLineMediaStream::InternalClose
virtual void InternalClose()
OpalLineEndPoint::defaultLine
PString defaultLine
Definition: lidep.h:299
OpalLine::IsTerminal
virtual PBoolean IsTerminal()
Definition: lid.h:940
OpalLineConnection::SendUserInputTone
virtual PBoolean SendUserInputTone(char tone, int duration)
OpalEndPoint::manager
OpalManager & manager
Definition: endpoint.h:807
OpalLineEndPoint::RemoveDevices
void RemoveDevices()
Definition: lidep.h:254
OpalLineInterfaceDevice::DialParams
Definition: lid.h:689
OpalLineConnection::OnClosedMediaStream
virtual void OnClosedMediaStream(const OpalMediaStream &stream)
OpalLineEndPoint::OpalLineEndPoint
OpalLineEndPoint(OpalManager &manager)
OpalLineEndPoint::lines
OpalLineList lines
Definition: lidep.h:298
OpalLineSilenceDetector
Definition: lidep.h:670
OpalLineEndPoint::GetLIDConnectionWithLock
PSafePtr< OpalLineConnection > GetLIDConnectionWithLock(const PString &token, PSafetyMode mode=PSafeReadWrite)
Definition: lidep.h:139
OpalLineMediaStream
Definition: lidep.h:555
OpalLineConnection::m_promptTone
OpalLineInterfaceDevice::CallProgressTones m_promptTone
Definition: lidep.h:545
OpalLineMediaStream::ReadPacket
virtual PBoolean ReadPacket(RTP_DataFrame &packet)
OpalLineInterfaceDevice
Definition: lid.h:51
OpalLineEndPoint::AddLinesFromDevice
virtual PBoolean AddLinesFromDevice(OpalLineInterfaceDevice &device)
OpalLineMediaStream::Open
virtual PBoolean Open()
OpalMediaStream::RequiresPatchThread
virtual PBoolean RequiresPatchThread() const
OpalLineMediaStream::notUsingRTP
bool notUsingRTP
Definition: lidep.h:661
OpalLineMediaStream::GetLine
OpalLine & GetLine()
Definition: lidep.h:654
OpalMediaStream
Definition: mediastrm.h:111
OpalMediaStream::mediaFormat
OpalMediaFormat mediaFormat
Definition: mediastrm.h:419
OpalLineConnection::minimumRingCount
unsigned minimumRingCount
Definition: lidep.h:543
OpalLineConnection::GetLine
OpalLine & GetLine()
Definition: lidep.h:516
OpalLineEndPoint::linesMutex
PMutex linesMutex
Definition: lidep.h:300
OpalLineMediaStream::OpalLineMediaStream
OpalLineMediaStream(OpalLineConnection &conn, const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource, OpalLine &line)
OpalLineEndPoint::SetDefaultLine
void SetDefaultLine(const PString &lineName)
OpalLineConnection::endpoint
OpalLineEndPoint & endpoint
Definition: lidep.h:540
OpalLineSilenceDetector::line
OpalLine & line
Definition: lidep.h:701
OpalConnection
Definition: connection.h:353
OpalLineConnection::PDECLARE_NOTIFIER
PDECLARE_NOTIFIER(PThread, OpalLineConnection, HandleIncoming)
OpalLineMediaStream::directLineNumber
unsigned directLineNumber
Definition: lidep.h:666
OpalLineInterfaceDevice::CallProgressTones
CallProgressTones
Definition: lid.h:584
endpoint.h
OpalLineInterfaceDevice::DialParams::m_dialStartDelay
unsigned m_dialStartDelay
Time in msec to wait between the dial tone detection and dialing the DTMF.
Definition: lid.h:702
OpalLineMediaStream::missedCount
unsigned missedCount
Definition: lidep.h:663
OpalLine
Definition: lid.h:906
OpalLineEndPoint::devices
OpalLIDList devices
Definition: lidep.h:297
OpalLineConnection::handlerThread
PThread * handlerThread
Definition: lidep.h:548
OpalEndPoint::GetConnectionWithLock
PSafePtr< OpalConnection > GetConnectionWithLock(const PString &token, PSafetyMode mode=PSafeReadWrite)
Definition: endpoint.h:513
OpalLineEndPoint::RemoveAllLines
void RemoveAllLines()
OpalLineEndPoint::MonitorLine
virtual void MonitorLine(OpalLine &line)
OpalLineConnection::SetConnected
virtual PBoolean SetConnected()
OpalLineEndPoint::MakeConnection
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)
OpalLineMediaStream::ReadData
virtual PBoolean ReadData(BYTE *data, PINDEX size, PINDEX &length)
OpalLineEndPoint::GetMediaFormats
virtual OpalMediaFormatList GetMediaFormats() const
OpalLineConnection::getDialDelay
unsigned int getDialDelay() const
Definition: lidep.h:536