upnpavcontroller/upnpavcontrollerclient/src/upnpavbrowsingsessionimpl.cpp
branchnew development branch with rendering state machine and other goodies
changeset 38 5360b7ddc251
parent 0 7f85d04be362
equal deleted inserted replaced
32:3785f754ee62 38:5360b7ddc251
     1 /*
     1 /*
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    20 
    20 
    21 
    21 
    22 
    22 
    23 // INCLUDES
    23 // INCLUDES
    24 // upnp stack api
    24 // upnp stack api
       
    25 #include <upnpstring.h>
       
    26 
       
    27 // dlnasrv / mediaserver api
    25 #include <upnpcontainer.h>
    28 #include <upnpcontainer.h>
    26 #include <upnpobjectlist.h>
    29 #include <upnpobjectlist.h>
    27 #include <upnpitem.h>
    30 #include <upnpitem.h>
    28 #include <upnpstring.h>
    31 
    29 
    32 // dlnasrv / avcontroller api
    30 // upnpframework / avcontroller api
       
    31 #include "upnpavdevice.h"
    33 #include "upnpavdevice.h"
    32 #include "upnpavbrowsingsessionobserver.h"
    34 #include "upnpavbrowsingsessionobserver.h"
    33 
    35 
    34 // avcontroller internal
    36 // avcontroller internal
    35 #include "upnpavcontrollerclient.h"
    37 #include "upnpavcontrollerclient.h"
   100     //delete iParser;
   102     //delete iParser;
   101     delete iDevice;    
   103     delete iDevice;    
   102     iDevice = NULL;
   104     iDevice = NULL;
   103     
   105     
   104     Cancel();
   106     Cancel();
   105     if( iMediaServerResourceReserved )
       
   106         {
       
   107         iServer.ReleaseMediaServer( (TInt)this );
       
   108         }    
       
   109     iServer.DestroyBrowsingSession( (TInt)this );
   107     iServer.DestroyBrowsingSession( (TInt)this );
   110     }
   108     }
   111 
   109 
   112 // --------------------------------------------------------------------------
   110 // --------------------------------------------------------------------------
   113 // CUPnPAVBrowsingSessionImpl::ConstructL
   111 // CUPnPAVBrowsingSessionImpl::ConstructL
   161         case EDeleteObject:
   159         case EDeleteObject:
   162             {
   160             {
   163             DeleteObjectCompletedL();
   161             DeleteObjectCompletedL();
   164             }
   162             }
   165             break;
   163             break;
   166 
       
   167         case EStartMediaServer:
       
   168             {
       
   169             StartMediaServerCompleteL();
       
   170             }
       
   171             break;
       
   172             
   164             
   173         default:
   165         default:
   174             __PANICD( __FILE__, __LINE__ );
   166             __PANICD( __FILE__, __LINE__ );
   175             break;            
   167             break;            
   176         }    
   168         }    
   214             {
   206             {
   215             iServer.CancelDeleteObject( (TInt)this );
   207             iServer.CancelDeleteObject( (TInt)this );
   216             }
   208             }
   217             break;
   209             break;
   218 
   210 
   219         case EStartMediaServer:
       
   220             {
       
   221             iServer.CancelReserveMediaServer( (TInt)this );
       
   222             }
       
   223             break;          
       
   224 
       
   225         default:
   211         default:
   226             __PANICD( __FILE__, __LINE__ );
   212             __PANICD( __FILE__, __LINE__ );
   227             break;            
   213             break;            
   228         }        
   214         }        
   229     }
   215     }
   271 // Returns used device
   257 // Returns used device
   272 // --------------------------------------------------------------------------
   258 // --------------------------------------------------------------------------
   273 const CUpnpAVDevice& CUPnPAVBrowsingSessionImpl::Device() const
   259 const CUpnpAVDevice& CUPnPAVBrowsingSessionImpl::Device() const
   274     {
   260     {
   275     return *iDevice;
   261     return *iDevice;
   276     }
       
   277 
       
   278 // --------------------------------------------------------------------------
       
   279 // CUPnPAVBrowsingSessionImpl::ReserveLocalMSServicesL
       
   280 // Reserves local media server
       
   281 // --------------------------------------------------------------------------
       
   282 void CUPnPAVBrowsingSessionImpl::ReserveLocalMSServicesL()
       
   283     {
       
   284     __LOG( "CUPnPAVBrowsingSessionImpl::ReserveLocalMSServicesL" );
       
   285     
       
   286     ResetL();
       
   287     
       
   288     if( iMediaServerResourceReserved )
       
   289         {
       
   290         if( iObserver )
       
   291             {
       
   292             iObserver->ReserveLocalMSServicesCompleted( KErrNone );
       
   293             }
       
   294         }
       
   295     else
       
   296         {
       
   297         iPendingOperation = EStartMediaServer;
       
   298         iServer.ReserveMediaServer( (TInt)this, iStatus );
       
   299         SetActive();            
       
   300         }    
       
   301     }
       
   302 
       
   303 // --------------------------------------------------------------------------
       
   304 // CUPnPAVBrowsingSessionImpl::CancelReserveLocalMSServicesL
       
   305 // Cancel reserve local media server
       
   306 // --------------------------------------------------------------------------
       
   307 void CUPnPAVBrowsingSessionImpl::CancelReserveLocalMSServicesL()
       
   308     {
       
   309     __LOG( "CUPnPAVBrowsingSessionImpl::CancelReserveLocalMSServicesL" );
       
   310     
       
   311     if( iPendingOperation == EStartMediaServer )
       
   312         {
       
   313         Cancel();
       
   314         }
       
   315     }
       
   316 
       
   317 // --------------------------------------------------------------------------
       
   318 // CUPnPAVBrowsingSessionImpl::ReleaseLocalMSServicesL
       
   319 // Release local media server
       
   320 // --------------------------------------------------------------------------
       
   321 void CUPnPAVBrowsingSessionImpl::ReleaseLocalMSServicesL()
       
   322     {
       
   323     __LOG( "CUPnPAVBrowsingSessionImpl::ReleaseLocalMSServicesL" );
       
   324     
       
   325     ResetL();
       
   326     
       
   327     if( iMediaServerResourceReserved )
       
   328         {
       
   329         iMediaServerResourceReserved = EFalse;
       
   330         
       
   331         User::LeaveIfError( iServer.ReleaseMediaServer( (TInt)this ) );
       
   332         }
       
   333     }
   262     }
   334 
   263 
   335 // --------------------------------------------------------------------------
   264 // --------------------------------------------------------------------------
   336 // CUPnPAVBrowsingSessionImpl::BrowseL
   265 // CUPnPAVBrowsingSessionImpl::BrowseL
   337 // Browse
   266 // Browse
   764     iBuffer3 = NULL;
   693     iBuffer3 = NULL;
   765 
   694 
   766     iPendingOperation = ENone;
   695     iPendingOperation = ENone;
   767     }    
   696     }    
   768 
   697 
   769 // --------------------------------------------------------------------------
       
   770 // CUPnPAVBrowsingSessionImpl::StartMediaServerCompleteL
       
   771 // Handle start media server
       
   772 // --------------------------------------------------------------------------
       
   773 void CUPnPAVBrowsingSessionImpl::StartMediaServerCompleteL()
       
   774     {
       
   775     __LOG( "CUPnPAVBrowsingSessionImpl::StartMediaServerCompleteL" );
       
   776     
       
   777     if( iObserver )
       
   778         {
       
   779 
       
   780         if( iStatus.Int() == EAVControllerStartMediaServerCompleted )
       
   781             {
       
   782             iMediaServerResourceReserved = ETrue;
       
   783             iObserver->ReserveLocalMSServicesCompleted( KErrNone );
       
   784             }
       
   785         else
       
   786             {
       
   787             iObserver->ReserveLocalMSServicesCompleted( iStatus.Int() );
       
   788             }
       
   789         
       
   790         }
       
   791     }
       
   792 
       
   793 // end of file
   698 // end of file