bluetooth/gavdp/public/gavdp.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2004-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 // forms the basis of the control plane for (Bluetooth) AV apps.
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef _GAVDP_H
       
    19 #define _GAVDP_H
       
    20 
       
    21 #include <bluetoothav.h>
       
    22 
       
    23 class MGavdpUser
       
    24 /**
       
    25 Mixin class for GAVDP-related events.
       
    26 
       
    27 To enforce thinking about the sequence of GAVDP events, these are pure
       
    28 @publishedPartner
       
    29 @released
       
    30 */
       
    31 	{
       
    32 public:
       
    33 /**
       
    34 Callback when a signalling channel has successfully been created
       
    35 Note this can be called by GAVDP without the client having called RGavdp::Connect
       
    36 The reason being that as soon as a GAVDP session is created AVDTP begins listening
       
    37 Therefore a remote device can connect to us.
       
    38 The GAVDP client can check the address to confirm if the device is that they originally Connect()ed
       
    39 @param aDeviceAddr the Bluetooth device address for which a signalling channel has been created
       
    40 */
       
    41 	virtual void GAVDP_ConnectConfirm(const TBTDevAddr& aDeviceAddr) =0;
       
    42 
       
    43 
       
    44 /**
       
    45 Callback when a remote SEP has been discovered
       
    46 @param aSEP the details of the remote SEP
       
    47 @see TAvdtpSEPInfo
       
    48 */
       
    49 	virtual void GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEP) =0;
       
    50 
       
    51 
       
    52 /**
       
    53 Callback when no more SEPs have been discovered on the remote device.
       
    54 This may be called without GAVDP_SEPDiscovered being called if the remote has no SEPs
       
    55 (such a remote would be in contravention of the specification however)
       
    56 */
       
    57 	virtual void GAVDP_SEPDiscoveryComplete() =0;	
       
    58 
       
    59 
       
    60 /**
       
    61 Callback when a capability from a remote SEP has been retrieved
       
    62 The client takes owenership of the capability given
       
    63 @param aCapability pointer to a capability. Ownership is transferred to the MGavdpUser implementor
       
    64 @see TAvdtpServiceCapability
       
    65 */
       
    66 	virtual void GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability) =0; // transfers ownership
       
    67 
       
    68 
       
    69 /**
       
    70 Callback when remote SEP has no more capabilities to be discovered
       
    71 */
       
    72 	virtual void GAVDP_SEPCapabilityComplete() =0;	
       
    73 
       
    74 /**
       
    75 Callback when the locally-initiated Abort stream has successfully completed
       
    76 */	
       
    77 	virtual void GAVDP_AbortStreamConfirm()=0;
       
    78 
       
    79 /**
       
    80 Callback when the locally-initiated Start stream has successfully completed
       
    81 */	
       
    82 	virtual void GAVDP_StartStreamsConfirm()=0;
       
    83 
       
    84 /**
       
    85 Callback when the locally-initiated Suspend stream has successfully completed
       
    86 */	
       
    87 	virtual void GAVDP_SuspendStreamsConfirm()=0;
       
    88 
       
    89 /**
       
    90 Callback when the locally-initiated Security Control message successfully completed
       
    91 @param aResponseData The data returned by the ACP - may be the same or different to that supplied by INT
       
    92 */	
       
    93 	virtual void GAVDP_SecurityControlConfirm(const TDesC8& aResponseData)=0;
       
    94 
       
    95 /**
       
    96 Callback when locally-initiated (re)configuration procedure successfully completes
       
    97 */	
       
    98 	virtual void GAVDP_ConfigurationConfirm()=0;	// configuration complete and SEP selected *AND* reconfigure confirm
       
    99 	
       
   100 	
       
   101 /**
       
   102 Callback when remote is beginning to configure a local SEP
       
   103 This cannot be rejected by the client at this stage - it must examine each
       
   104 capability proposed by the GAVDP peer.
       
   105 @param aLocalSEID the SEID of the local SEP being configured
       
   106 @param aRemoteSEID the SEID of the remote SEP configuring us
       
   107 */
       
   108 	virtual void GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID) =0;
       
   109 	
       
   110 	
       
   111 /**
       
   112 Callback when each capability is being proposed by the peer during configuration
       
   113 Each capability can be refused, but doing so completes whole configure operation
       
   114 @return the client's result - eg whether it is accepting or rejecting the configuration
       
   115 @param aCapability The capability being proposed. Ownership transferred to client,iff processes in the function return KErrNone.
       
   116 */
       
   117 	virtual TInt GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability) =0;
       
   118 
       
   119 /**
       
   120 Callback when remotely initiated configuration of local SEP is completed	
       
   121 The client can still error, as the local side may have expected to see more capabilities proposed
       
   122 @return The client's acceptance or rejection of the whole configuration
       
   123 */	
       
   124 	virtual TInt GAVDP_ConfigurationEndIndication() =0;
       
   125 
       
   126 /**
       
   127 Callback when the remote is trying to Start a stream
       
   128 @param aSEID the SEID of the local SEP being started
       
   129 @return The client's acceptance or rejection of the stream start. The return value should reflect the outcome
       
   130 of the client's ability to handle this command.
       
   131 
       
   132 The allowable error codes are defined in the Bluetooth SIG AVDTP specification and profiles design to operate
       
   133 above that layer, such as GAVDP. However those "local" error code values should be offset by the Symbian
       
   134 KErrAvdtpSignallingErrorBase (-18045) to convert to system-wide, absolute error codes.
       
   135 
       
   136 For example; the error code for NOT_SUPPORTED_COMMAND = 25
       
   137 Therefore, the system code would be (-18045)-25 = -18070
       
   138 */
       
   139 	virtual TInt GAVDP_StartIndication(TSEID aSEID) =0;
       
   140 
       
   141 
       
   142 /**
       
   143 Callback when the remote is trying to Suspend a stream
       
   144 @param aSEID the SEID of the local SEP being suspended
       
   145 @return The client's acceptance or rejection of the suspension. The return value should reflect the outcome
       
   146 of the client's ability to handle this command.
       
   147 
       
   148 The allowable error codes are defined in the Bluetooth SIG AVDTP specification and profiles design to operate
       
   149 above that layer, such as GAVDP. However those "local" error code values should be offset by the Symbian
       
   150 KErrAvdtpSignallingErrorBase (-18045) to convert to system-wide, absolute error codes.
       
   151 
       
   152 For example; the error code for NOT_SUPPORTED_COMMAND = 25
       
   153 Therefore, the system code would be (-18045)-25 = -18070
       
   154 */
       
   155 	virtual TInt GAVDP_SuspendIndication(TSEID aSEID) =0;
       
   156 
       
   157 
       
   158 /**
       
   159 Callback when the remote is sending Security Control information
       
   160 @param aSEID the SEID of the local SEP for which security control is for
       
   161 @param aSecurityDataInOut Security Data inbound. The client may change this descriptor for the outbound response
       
   162 @return The client's acceptance or rejection of the security control indication.
       
   163 */
       
   164 	virtual TInt GAVDP_SecurityControlIndication(TSEID aSEID, TDes8& aSecurityDataInOut) =0;
       
   165 
       
   166 /**
       
   167 Callback when the remote has Aborted the stream
       
   168 @param aSEID the SEID of the local SEP which has been Aborted
       
   169 */
       
   170 	virtual void GAVDP_AbortIndication(TSEID aSEID) =0;
       
   171 	
       
   172 /**
       
   173 Callback when the remote end has Released a stream
       
   174 The user-plane bearers will subsequently error with KErrDisconnected.
       
   175 @param aSEID the SEID of the local SEP which was been released
       
   176 */
       
   177 	virtual void GAVDP_ReleaseIndication(TSEID aSEID) =0;
       
   178 
       
   179 
       
   180 /**
       
   181 Callback when a bearer has been created for a session in the stream.
       
   182 The session the bearer is for can be examined from the socket address given in the callback
       
   183 Each socket created in this way is created on the client's socket server session,
       
   184 and responsibility for socket closure is ceded to the client.
       
   185 @param aSocket the socket created on the client's socket server session.
       
   186 @param aAddress the socket address (containing SEID, Session type)
       
   187 @see TAvdtpSockAddr
       
   188 */
       
   189 	virtual void GAVDP_BearerReady(RSocket aSocket, const TAvdtpSockAddr& aAddress)=0;
       
   190 
       
   191 
       
   192 /**
       
   193 Callback when a GAVDP error occurs
       
   194 @param aError system-wide or GAVDP or AVDTP error code, for example 
       
   195 			  KErrDisconnected if the signalling channel is disconnected
       
   196 			  KErrNotReady if GAVDP or AVDTP is not in a valid state to perform an action
       
   197 			  KErrUnknown if a stream is not currently known to AVDTP.  This is likely to occur 
       
   198 						  in the case where a user has closed their bearer socket(s) and GAVDP
       
   199 						  tries to perform an operation requiring a stream.  
       
   200 			  KErrDied if an unrecoverable internal error occurs (in which case clients should re-start GAVDP)
       
   201 			  Clients should note that for system wide error codes the reasons given are for
       
   202 			  errors generated by AVDTP.  There is a small chance that they can be passed up in 
       
   203 			  another situation if the error originates from a call on another part of the system.
       
   204 @param aErrorData extra data relating to the error - the client can deduce the nature based on their GAVDP state and the spec
       
   205 @see TAvdtpConfigRejectPckgBuf as an example of what may be passed back
       
   206 */
       
   207 	virtual void GAVDP_Error(TInt aError, const TDesC8& aErrorData) =0;
       
   208 	};
       
   209 	
       
   210 class CGavdp;
       
   211 
       
   212 NONSHARABLE_CLASS(RGavdp)
       
   213 /**
       
   214 Represents a single GAVDP session to a remote device.
       
   215 If an app wishes to (eg) listen after connecting a GAVDP link it should 
       
   216 instantiate another RGavdp.
       
   217 
       
   218 Note this class uses internal active objects to provide the underlying 
       
   219 services. Clients should be careful to allow these objects to run.
       
   220 
       
   221 One RGavdp represents one remote device.
       
   222 If an inbound connection is made then a new RGavdp must be instantiated to 
       
   223 form a stream to another device.
       
   224 Once RGavdp instance may be used to manage more than 1 local SEP. This is 
       
   225 useful if the client only ever intends to support one active stream, but 
       
   226 wishes to select from >1 codec.
       
   227 Alternatively >1 instance of RGavdp may be created, with a desire to manage 
       
   228 each local SEP with each RGavdp instance. This would allow >1 active stream.
       
   229 
       
   230 @publishedPartner
       
   231 @released
       
   232 */
       
   233 	{
       
   234 public:
       
   235 	IMPORT_C RGavdp();
       
   236 
       
   237 	IMPORT_C TInt Open(MGavdpUser& aServiceUser, RSocketServ& aSocketServer);
       
   238 	IMPORT_C TInt Listen();
       
   239 
       
   240 	IMPORT_C void Close();
       
   241 	IMPORT_C void Cancel();
       
   242 	
       
   243 	IMPORT_C void Connect(const TBTDevAddr& aRemoteAddr);
       
   244 	IMPORT_C void DiscoverRemoteSEPs();
       
   245 	IMPORT_C void GetRemoteSEPCapabilities(TSEID aSEID, const TAvdtpServiceCategories& aInterestingCategories);
       
   246 
       
   247 	IMPORT_C TInt RegisterSEP(TAvdtpSEPInfo& aInfo);
       
   248 
       
   249 	IMPORT_C TInt BeginConfiguringRemoteSEP(TSEID aRemoteSEID, TSEID aLocalSEID);
       
   250 	IMPORT_C TInt BeginConfiguringLocalSEP(TSEID aSEID);
       
   251 	IMPORT_C TInt AddSEPCapability(const TAvdtpServiceCapability& aCapability);
       
   252 	IMPORT_C void CommitSEPConfiguration();
       
   253 	
       
   254 	IMPORT_C void StartStream(TSEID aSEID);
       
   255 	IMPORT_C void SuspendStream(TSEID aSEID);
       
   256 	IMPORT_C void AbortStream(TSEID aSEID);
       
   257 	
       
   258 	IMPORT_C void SendSecurityControl(TSEID aSEID, const TDesC8& aSecurityData);
       
   259 	
       
   260 	IMPORT_C TInt CreateBearerSockets(TSEID aSEID, TBool aIgnored1, TBool aIgnored2);
       
   261 	IMPORT_C TInt MaxSecurityControlLength();
       
   262 
       
   263 	IMPORT_C TInt CreateBearerSockets(TSEID aSEID);
       
   264 	IMPORT_C TInt Shutdown();
       
   265 public:
       
   266 	void UnbindBody();
       
   267 	
       
   268 private:
       
   269 	CGavdp*			iGavdpImp;
       
   270 	};
       
   271 
       
   272 /**
       
   273 Panics = client doing something wrong
       
   274 **/
       
   275 
       
   276 enum TGavdpPanic
       
   277 	{
       
   278 	EGavdpBadState = 0,
       
   279 	EGavdpResponseDataExpected = 1,
       
   280 	EGavdpSEPMustBeRegisteredBeforeListen = 2,
       
   281 	EGavdpSEPMustBeRegisteredBeforeConnect = 3,
       
   282 	EGavdpAlreadyOpen = 4,
       
   283 	EGavdpNotOpen = 5,
       
   284 	EGavdpUserSuppliedBadSEID = 6,
       
   285 	EGavdpBadRemoteAddress = 7,
       
   286 	EGavdpClientHasRepliedInCorrectly = 8,
       
   287 	/** @deprecated Should use EGavdpShutdownNotPermittedAfterRemoteSEPConfigured instead */
       
   288 	EGavdpShutdownNotPermittedWhenStreaming = 9,
       
   289 	EGavdpShutdownNotPermittedAfterRemoteSEPConfigured = 9,
       
   290 	/**Reference value used to determine if error value is below max panic value */
       
   291 	EGavdpMaxPanicErr = -940,
       
   292 	/**Panic used when the user attempts to create a bearer whilst one is already open */
       
   293 	EGavdpOpenInBadState = -999,
       
   294 	/**Reference value used to determine if error value exceeds min panic value */
       
   295 	EGavdpMinPanicErr = -999,
       
   296 	};
       
   297 		
       
   298 #endif //_GAVDP_H