bluetooth/btstack/avdtp/avdtpSignallingSession.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Signalling session
       
    15 // A signalling session represents one RGavdp object.  It is-a transport session.
       
    16 // Each signalling session is bound to a signalling channel - a signalling channel can support many
       
    17 // signalling sessions.
       
    18 // The multiplexing allows for many applications to stream to the same remote device
       
    19 // A signalling session also "manages" each of the stream endpoints registered by an RGavdp client.
       
    20 // A RGavdp client may register many (local) seps.
       
    21 // The signalling session receives indications from the signalling channel - since the signalling channel
       
    22 // (intentionally) doesn't know which SEPs are managed by which session various protocol events are
       
    23 // offered to all of the signalling sessions.
       
    24 // The signalling sessions should then see if they manage a sep for which the protocol event has happened
       
    25 // and "consume" the event.
       
    26 // At certain stages in the protocol state machine the local seps may "grow" a stream.  Subsequent protocol
       
    27 // primitives may then be called via the sep's stream.
       
    28 // The specification does not define Signalling Sessions.  However they are required to fulfill the need to 
       
    29 // support streams from multiple applications to the same target device. 
       
    30 // the session is then "fixed" to that remote.  Therefore all SEPs managed by the session
       
    31 // become available only for use with that remote.  The user *can* (if this is important)
       
    32 // still use multiple SEPs by placing one SEP in one RGavdp (implies one signalling session)
       
    33 // a future extension would be to see from which remote address a configure had been received
       
    34 // Hence there is one SEP pointer recording the SEP undergoing configuration
       
    35 // 
       
    36 //
       
    37 
       
    38 /**
       
    39  @note This design has a restriction at this point in time. Once connected to a remote
       
    40  @note At present this design allows for at most one SEP to undergo configuration at a time from all remote devices
       
    41 */
       
    42 
       
    43 #ifndef AVDTPSIGNALLINGSESSION_H
       
    44 #define AVDTPSIGNALLINGSESSION_H
       
    45 
       
    46 #include "avdtpTransportSession.h"
       
    47 #include "avdtpStream.h"
       
    48 
       
    49 
       
    50 const TInt KAvdtpACPReleaseChannelCloseTimeout = 10000000;
       
    51 
       
    52 
       
    53 class CTransportChannel;
       
    54 class CAvdtpSAP;
       
    55 class CAvdtpProtocol;
       
    56 class CSignallingChannel;
       
    57 class CSEPConfigurator;
       
    58 class CLocalSEP;
       
    59 
       
    60 
       
    61 NONSHARABLE_CLASS(CSignallingSession) : public CTransportSession, public XAvdtpSignalReceiver, public MAvdtpStreamNotify
       
    62 	{
       
    63 friend class CLocalSEPConfigurator;
       
    64 friend class CRemoteSEPConfigurator;
       
    65 
       
    66 public:
       
    67 	static CSignallingSession* NewLC(CAvdtpProtocol& aProtocol, CAvdtpSAP& aSAP);
       
    68 	static CSignallingSession* NewL(CAvdtpProtocol& aProtocol, CAvdtpSAP& aSAP);
       
    69 
       
    70 	virtual TInt SetOption(TUint aLevel, TUint aName, const TDesC8 &aOption);
       
    71 	virtual TInt GetOption(TUint aLevel, TUint aName, TDes8& aOption) const; 
       
    72 	virtual void Ioctl(TUint aLevel, TUint aName, const TDesC8* aOption);
       
    73 	virtual void CancelIoctl(TUint aLevel, TUint aName);
       
    74 	virtual TInt Send(RMBufChain& aData, TUint aOptions, TSockAddr* aAddr);
       
    75 	virtual TInt GetData(RMBufChain& aData);
       
    76 	virtual void DoShutdown();
       
    77 
       
    78 	virtual TInt ActiveOpen();
       
    79 	~CSignallingSession();
       
    80 
       
    81 private:
       
    82 //from signal receiver - we're interested in most, but not all service upcalls
       
    83 	virtual TInt DiscoverIndication(TAvdtpTransactionLabel aLabel, CAvdtpOutboundSignallingMessage& aDiscoverResponsePacket);
       
    84 	virtual TInt GetCapsIndication(TAvdtpTransactionLabel aLabel,
       
    85 									TSEID aSEID,
       
    86 									CAvdtpOutboundSignallingMessage& aGetCapsResponseMessage);
       
    87 	virtual TInt SetConfigIndication(TAvdtpTransactionLabel aLabel, TSEID aLocalSEID,
       
    88 											TSEID aINTSEID, RBuf8& aConfigData);
       
    89 	virtual TInt GetConfigIndication(TAvdtpTransactionLabel aLabel, TSEID aLocalSEID,
       
    90 									CAvdtpOutboundSignallingMessage& /*aGetConfigResponseMessage*/);
       
    91 	virtual TInt ReconfigIndication(TAvdtpTransactionLabel aLabel,
       
    92 													TSEID aLocalSEID,
       
    93 													RBuf8& aNewConfig);
       
    94 	virtual TInt OpenIndication(TSEID aLocalSEID);
       
    95 	virtual TInt StartIndication(TAvdtpTransactionLabel aLabel, TSEID aLocalSEID);
       
    96 	virtual TInt ReleaseIndication(TAvdtpTransactionLabel aLabel, TSEID aLocalSEID);
       
    97 	virtual TInt SuspendIndication(TAvdtpTransactionLabel aLabel, TSEID aLocalSEID);
       
    98 	virtual TInt AbortIndication(TAvdtpTransactionLabel aLabel, TSEID aLocalSEID);
       
    99 	virtual TInt SecurityControlIndication(TAvdtpTransactionLabel aLabel, TSEID aLocalSEID, const HBufC8* aSecurityData);
       
   100 
       
   101 	virtual void SignallingChannelError(TInt aError);
       
   102 // protocol confirms
       
   103 // no labels needed
       
   104 
       
   105 	virtual void DiscoverConfirm(TInt aResult, const TAvdtpInternalDiscoverConfirm* const aConfirm);
       
   106 	virtual void GetCapsConfirm(TInt aResult, TSEID aRemoteSEID, TAvdtpServiceCatBitMask aSeen);
       
   107 	virtual void AbortConfirm(TSEID aRemoteSEID);
       
   108 	virtual void SecurityControlConfirm(TInt aResult, TSEID aRemoteSEID, const TDesC8& aResponseData);
       
   109 
       
   110 // interface from stream
       
   111 	virtual void StreamStarted(TSEID aLocalSEID);
       
   112 	virtual void StreamSuspended(TSEID aLocalSEID);
       
   113 	virtual void StreamAccepted(TSEID aLocalSEID, TSEID aRemoteSEID, TBool aWithReporting, TBool aWithRecovery);
       
   114 	virtual void StreamConfigured(TSEID aLocalSEID, TInt aError, TAvdtpServiceCategory aFailedCategory);
       
   115 	virtual void StreamInitiatedServiceFailed(const CAVStream& aStream, TInt aError);
       
   116 	virtual void StreamReadyForStartIndication(const TAvdtpTransactionLabel aLabel, const TSEID aSEID);
       
   117 
       
   118 // callbacks from signalling channel
       
   119 	virtual void ServiceError(TInt aError);
       
   120 	virtual void SignallingChannelReady(CSignallingChannel& aNewChannel);
       
   121 
       
   122 private:
       
   123 	void DoConfigureStreamL(RBuf8& aConfigBuffer,
       
   124 							CLocalSEP& aLocalSEP,
       
   125 							TSEID aRemoteSEID,
       
   126 							TBool aReportingConfigured,
       
   127 							TBool aRecoveryConfigured);
       
   128 	TInt SendAbort(TSEID aRemoteSEID);
       
   129 	void CreateLocalSEPL(TAvdtpSEPInfo& aSEPInfo); // note, not const ref
       
   130 	CLocalSEP& FindLocalSEPL(TSEID aSEID) const;
       
   131 	CLocalSEP* FindLocalSEP(TSEID aSEID) const;
       
   132  
       
   133 	CSignallingSession(CAvdtpProtocol& aProtocol, CAvdtpSAP& aSAP);
       
   134 	void ConstructL();
       
   135 	TInt DoAddCapabilitySetOpt(const TDesC8& aOption);
       
   136 	inline void CompleteBasicService(TInt aErr);
       
   137 	
       
   138 	CAVStream* FindStreamFromRemoteSEID(const TSEID& aRemoteSEID) const;
       
   139 	void ClearSignallingChannel();
       
   140 	void DestroyLocalSEPs();
       
   141 	void DestroyStream(CAVStream* aStream, TInt aError);
       
   142 	
       
   143 private:
       
   144 	CSignallingChannel*		iSignallingChannel; // non-owned
       
   145 	CSEPConfigurator*		iSEPConfigurator;
       
   146 	mutable TDblQue<CLocalSEP>	iLocalSEPs; // those awaiting discover (by "our" app)
       
   147 
       
   148 	TBool					iIsListening;
       
   149 	};
       
   150 	
       
   151 /*
       
   152 @internalComponent
       
   153 */
       
   154 // goes through to see if remote has proposed unsupported local categories
       
   155 NONSHARABLE_CLASS(CCapabilityNotAllowedVisitor) : public CCapabilityVisitor
       
   156 	{
       
   157 public:
       
   158 	CCapabilityNotAllowedVisitor(TAvdtpServiceCategories aLocallySupported);
       
   159 	virtual TBool Capability(TAvdtpServiceCategory aCat);
       
   160 	inline TBool IsValid() const;
       
   161 	inline TAvdtpServiceCategory WrongCategory() const;
       
   162 private:
       
   163 	TAvdtpServiceCategories iLocallySupported;
       
   164 	TBool	iIsValid;
       
   165 	TAvdtpServiceCategory iWrongCategory;
       
   166 	};
       
   167 
       
   168 	
       
   169 #endif //AVDTPSIGNALLINGSESSION_H
       
   170