bluetooth/gavdp/source/gavdpIf.cpp
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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @publishedPartner
       
    19  @released
       
    20 */
       
    21 
       
    22 #include <gavdp.h>
       
    23 #include "gavdpInternal.h"
       
    24 
       
    25 /**
       
    26 Default Constructor
       
    27 */
       
    28 EXPORT_C RGavdp::RGavdp() 
       
    29 : iGavdpImp(NULL)
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34 Open a GAVDP session.
       
    35 @note not to be confused with the "Open" primitive in the GAVDP spec. This is 
       
    36 merely opening the handle in the Symbian OS sense.
       
    37 @param aServiceUser a reference to a MGavdpUser mixin for GAVDP callback 
       
    38 events.
       
    39 @param aSocketServer reference to the client's Socket Server session. 
       
    40 @return system-wide error
       
    41 @see RegisterSEP
       
    42 */
       
    43 EXPORT_C TInt RGavdp::Open(MGavdpUser& aServiceUser, RSocketServ& aSocketServer)
       
    44 	{
       
    45 	__ASSERT_ALWAYS(iGavdpImp==NULL,Panic(EGavdpAlreadyOpen));
       
    46 	
       
    47 	TRAPD(res, iGavdpImp = CGavdp::NewL(aServiceUser, aSocketServer, *this));
       
    48 	return res;
       
    49 	}
       
    50 	
       
    51 /**
       
    52 Closes the GAVDP session and frees all resources associated with it.
       
    53 This function should not be called from within a client's implementation of 
       
    54 any MGavdpUser (upcall) method.
       
    55 @note not to be confused with the "Close" primitive in the GAVDP spec. This is 
       
    56 merely closing the handle in the Symbian OS sense.
       
    57 @note However, if this is Closed when streams are active, the Bluetooth 
       
    58 subsystem shall Release all Streams managed by this RGavdp instance.
       
    59 @note that the closure of any bearer sockets created remains the 
       
    60 responsibility of the client.
       
    61 */
       
    62 EXPORT_C void RGavdp::Close()
       
    63 	{
       
    64 	delete iGavdpImp;
       
    65 	iGavdpImp = NULL;
       
    66 	}
       
    67 	
       
    68 /**
       
    69 Cancel the outstanding client request.
       
    70 As per usual Symbian OS Cancel semantics, this method does not guarantee that 
       
    71 the outstanding request was "undone".
       
    72 Therefore to reset each sides' state the client should consider sending an 
       
    73 Abort too.
       
    74 @see RGavdp::AbortStream
       
    75 */
       
    76 EXPORT_C void RGavdp::Cancel()
       
    77 	{
       
    78 	if(iGavdpImp!=NULL)
       
    79 		{
       
    80 		iGavdpImp->Cancel();	
       
    81 		}
       
    82 	}
       
    83 
       
    84 /**
       
    85 Connects a GAVDP session - i.e. creates an AVDTP signalling channel to a 
       
    86 remote device.
       
    87 The signalling channel may already exist, in which case this session is added 
       
    88 as a user of that channel.
       
    89 The necessary multiplexing is implemented in AVDTP, so the client need not be 
       
    90 concerned with this.
       
    91 @param aRemoteAddr the Bluetooth device address of the remote GAVDP entity.
       
    92 */
       
    93 EXPORT_C void RGavdp::Connect(const TBTDevAddr& aRemoteAddr)
       
    94 	{
       
    95 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
    96 	iGavdpImp->Connect(aRemoteAddr);
       
    97 	}
       
    98 	
       
    99 /**
       
   100 Discover the Stream endpoints (SEPs) on the remote device.
       
   101 Callbacks on MGavdpUser will be called as a result of this call.
       
   102 @pre a Signalling channel must have been successfully created
       
   103 @see MGavdpUser::GAVDP_SEPDiscovered
       
   104 */
       
   105 EXPORT_C void RGavdp::DiscoverRemoteSEPs()
       
   106 	{
       
   107 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   108 	iGavdpImp->DiscoverRemoteSEPs();
       
   109 	}
       
   110 	
       
   111 /**
       
   112 Get the capabilities of a remote Stream Endpoint (SEP).
       
   113 Callbacks on MGavdpUser will be called for the intersection of capabilities 
       
   114 that the remote supports and that the local GAVDP user is interested in using. 
       
   115 @param aSEID the ID of the remote SEP for which capabilities are to be 
       
   116 retrieved.
       
   117 @param aInterestingCategories the categories the local GAVDP client is 
       
   118 interested in.
       
   119 */
       
   120 EXPORT_C void RGavdp::GetRemoteSEPCapabilities(TSEID aSEID, const TAvdtpServiceCategories& aInterestingCategories)
       
   121 	{
       
   122 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   123 	iGavdpImp->GetRemoteSEPCapabilities(aSEID, aInterestingCategories);
       
   124 	}
       
   125 	
       
   126 /**
       
   127 Begin configuring (or reconfiguring) a remote SEP.
       
   128 Subsequent calls are used to add each configuration required.
       
   129 @see RGavdp::AddSEPCapability
       
   130 @param aRemoteSEID the ID of the remote SEP.
       
   131 @param aLocalSEID the ID of the local SEP.
       
   132 @return system-wide error.
       
   133 */	
       
   134 EXPORT_C TInt RGavdp::BeginConfiguringRemoteSEP(TSEID aRemoteSEID, TSEID aLocalSEID)
       
   135 	{
       
   136 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   137 	return iGavdpImp->BeginConfiguringRemoteSEP(aRemoteSEID, aLocalSEID);
       
   138 	}
       
   139 	
       
   140 /**
       
   141 Begin configuring (or reconfiguring) a local SEP.
       
   142 Subsequent calls are used to add each configuration required.
       
   143 @see RGavdp::AddSEPCapability
       
   144 @param aSEID the ID of the local SEP.
       
   145 @return system-wide error.
       
   146 */	
       
   147 EXPORT_C TInt RGavdp::BeginConfiguringLocalSEP(TSEID aSEID)
       
   148 	{
       
   149 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   150 	return iGavdpImp->BeginConfiguringLocalSEP(aSEID);
       
   151 	}
       
   152 	
       
   153 /**
       
   154 Add a particular capability into a SEP.
       
   155 When called on a local SEP this equates to adding capabilities into the SEP.
       
   156 When called on a remote SEP this equates to configuring the SEP.
       
   157 @param aCapability a capability
       
   158 @see TAvdtpServiceCapability
       
   159 @return system-wide error.
       
   160 */	
       
   161 EXPORT_C TInt RGavdp::AddSEPCapability(const TAvdtpServiceCapability& aCapability)
       
   162 	{
       
   163 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   164 	return iGavdpImp->AddSEPCapability(aCapability);
       
   165 	}
       
   166 	
       
   167 /**
       
   168 Finalises the (re)configuration of the SEP
       
   169 */
       
   170 EXPORT_C void RGavdp::CommitSEPConfiguration()
       
   171 	{
       
   172 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   173 	iGavdpImp->CommitSEPConfiguration();
       
   174 	}
       
   175 	
       
   176 /**
       
   177 Start stream
       
   178 @param aSEID the SEID of the local or remote SEP that requires starting
       
   179 */
       
   180 EXPORT_C void RGavdp::StartStream(TSEID aSEID)
       
   181 	{
       
   182 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   183 	iGavdpImp->StartStream(aSEID);
       
   184 	}
       
   185 	
       
   186 /**
       
   187 Suspend stream
       
   188 @note that the remote may not support Suspend, and an 
       
   189 AVDTP NOT_SUPPORTED_COMMAND error may result.
       
   190 In this case the client should consider Closing the stream.
       
   191 @param aSEID the SEID of the local or remote SEP that requires suspending.
       
   192 */
       
   193 EXPORT_C void RGavdp::SuspendStream(TSEID aSEID)
       
   194 	{
       
   195 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   196 	iGavdpImp->SuspendStream(aSEID);
       
   197 	}
       
   198 	
       
   199 /**
       
   200 Abort stream
       
   201 @note that once complete the state of the SEP will be Idle. Thus to restream, 
       
   202 the SEP has to be reconfigured, opened and started.
       
   203 @param aSEID the SEID of the local or remote SEP that requires aborting.
       
   204 */	
       
   205 EXPORT_C void RGavdp::AbortStream(TSEID aSEID)
       
   206 	{
       
   207 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   208 	iGavdpImp->AbortStream(aSEID);
       
   209 	}
       
   210 	
       
   211 /**
       
   212 Send security control data to remote SEP.
       
   213 The meaning of this is dependent on the configured Content Protection method. 
       
   214 @see TAvdtpContentProtectionCapabilities
       
   215 @param aSEID the seid of the remote SEP
       
   216 @param aSecurityData the security data
       
   217 */
       
   218 EXPORT_C void RGavdp::SendSecurityControl(TSEID aSEID, const TDesC8& aSecurityData)
       
   219 	{
       
   220 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   221 	iGavdpImp->SendSecurityControl(aSEID, aSecurityData);	
       
   222 	}
       
   223 
       
   224 /**
       
   225 Register an extra local SEP.
       
   226 @param aInfo reference containing SEP information. Note the SEID assigned by 
       
   227 AVDTP will be written back into aInfo.
       
   228 @return system-wide error
       
   229 */
       
   230 EXPORT_C TInt RGavdp::RegisterSEP(TAvdtpSEPInfo& aInfo)
       
   231 	{
       
   232 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   233 	return iGavdpImp->RegisterSEP(aInfo);
       
   234 	}
       
   235 	
       
   236 /**
       
   237 Listen for inbound signalling channel connections.
       
   238 This is useful when the signalling channel is lost.
       
   239 Note: This function will not connect the session to any existing connected 
       
   240 signalling channels.
       
   241 The session will only be connected upon the next channel being connected. 
       
   242 Users should use Connect instead if they intend to connect to existing 
       
   243 signalling channels.
       
   244 @pre At least SEP shall have been registered
       
   245 @see RGavdp::RegisterSEP(TAvdtpSEPInfo& aInfo)
       
   246 @panic The client thread will be panicked if Listen is called prior to any 
       
   247 SEPs being registered.
       
   248 @return system-wide error code
       
   249 */
       
   250 EXPORT_C TInt RGavdp::Listen()
       
   251 	{
       
   252 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   253 	return iGavdpImp->Listen();
       
   254 	}
       
   255 
       
   256 /**
       
   257 Creates bearers (in the form of sockets) for sessions on the stream.
       
   258 The sessions are media + optional reporting + optional recovery.
       
   259 The sockets will be created on the client's Socket Server session.
       
   260 The sockets may then be passed into RTP for its use.
       
   261 If the sockets are passed to RTP the client still has the responsibility of 
       
   262 closing them.
       
   263  - i.e. neither RTP nor GAVDP will close the sockets.
       
   264 The reporting/recovery config is already known by the stream. All the required
       
   265 bearers will be created.
       
   266 
       
   267 @param aSEID The SEID of the remote SEP for which the sockets are required.
       
   268 @param aIgnored1 Source compatibility place holder
       
   269 @param aIgnored2 Source compatibility place holder
       
   270 @return system-wide error code
       
   271 
       
   272 @see RGavdp::CreateBearerSockets(TSEID aSEID)
       
   273 @deprecated
       
   274 */
       
   275 EXPORT_C TInt RGavdp::CreateBearerSockets(TSEID aSEID, TBool /*aIgnored1*/, TBool /*aIgnored2*/)
       
   276 	{
       
   277 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   278 	return iGavdpImp->CreateBearerSockets(aSEID);
       
   279 	}
       
   280 
       
   281 /**
       
   282 Creates bearers (in the form of sockets) for sessions on the stream.
       
   283 The sessions are media + optional reporting + optional recovery.
       
   284 The sockets will be created on the client's Socket Server session.
       
   285 The sockets may then be passed into RTP for its use.
       
   286 If the sockets are passed to RTP the client still has the responsibility of 
       
   287 closing them.
       
   288  - i.e. neither RTP nor GAVDP will close the sockets.
       
   289 The reporting/recovery config is already known by the stream. All the required
       
   290 bearers will be created. 
       
   291 
       
   292 @param aSEID The SEID of the remote SEP for which the sockets are required.
       
   293 @return system-wide error code
       
   294 */
       
   295 EXPORT_C TInt RGavdp::CreateBearerSockets(TSEID aSEID)
       
   296 	{
       
   297 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   298 	return iGavdpImp->CreateBearerSockets(aSEID);
       
   299 	}
       
   300 
       
   301 /**
       
   302 This function returns the deprecated value KMaxAvdtpSecurityControlInfo so as 
       
   303 to ensure that the return value is what partners will expect during the 
       
   304 transition period from the use of the old constant to this new API.
       
   305 When the constant is removed from BluetoothAV.h it should be moved to an 
       
   306 internal header.
       
   307 @return KMaxAvdtpSecurityControlInfo
       
   308 */
       
   309 EXPORT_C TInt RGavdp::MaxSecurityControlLength()
       
   310 	{
       
   311 	return KMaxAvdtpSecurityControlInfo;
       
   312 	}
       
   313 
       
   314 /**
       
   315 Disconnects the RGavdp session from the signalling channel, but does not destroy the local SEPs owned
       
   316 by the signalling channel. Must only be called if the remote SEP has not yet been configured -
       
   317 if the remote SEP has been configured then AbortStream() should be called.
       
   318 
       
   319 @return system-wide error code
       
   320 @panic If remote SEP configured
       
   321 */
       
   322 
       
   323 EXPORT_C TInt RGavdp::Shutdown()
       
   324 	{
       
   325 	__ASSERT_ALWAYS(iGavdpImp!=NULL,Panic(EGavdpNotOpen));
       
   326 	TInt ret = iGavdpImp->Shutdown();
       
   327 	if (ret==KErrNotReady) 
       
   328 		{
       
   329 		Panic(EGavdpShutdownNotPermittedAfterRemoteSEPConfigured);
       
   330 		}
       
   331 	return ret;
       
   332 	}
       
   333 	
       
   334 void RGavdp::UnbindBody()
       
   335 	{
       
   336 	iGavdpImp = NULL;
       
   337 	}
       
   338 
       
   339 	
       
   340 // EOF