multimediacommscontroller/mmccvideosourcesink/src/mccvideosinkimpl.cpp
changeset 19 f58ead8cf73c
parent 0 1bce908db942
equal deleted inserted replaced
15:b25d6a5c0a63 19:f58ead8cf73c
    29 #include "mccinternalevents.h"
    29 #include "mccinternalevents.h"
    30 #include "CXPSPacketSink.h"
    30 #include "CXPSPacketSink.h"
    31 #include "mmcccodecamr.h"
    31 #include "mmcccodecamr.h"
    32 #include "mccvideosinkuser.h"
    32 #include "mccvideosinkuser.h"
    33 #include "mccdef.h"
    33 #include "mccdef.h"
    34 #include "mccredrawhandler.h"
       
    35 #include "mccinternaldef.h"
    34 #include "mccinternaldef.h"
    36 #include <videoplayer2.h>
    35 #include <videoplayer2.h>
    37 
    36 
    38 // CONSTANTS
    37 // CONSTANTS
    39 
    38 
   137     __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl window ordinal priority:", 
   136     __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl window ordinal priority:", 
   138                                   iSettings.iWindowOrdinalPriority )
   137                                   iSettings.iWindowOrdinalPriority )
   139     __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl rotation:", 
   138     __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl rotation:", 
   140                                   iSettings.iRotation )
   139                                   iSettings.iRotation )
   141     
   140     
   142 	// Create window group
   141     CreateWindowingElementsL(iSettings);
   143 	TInt groupId = iRwSession.GetFocusWindowGroup();
       
   144     iRwGroup = new (ELeave) RWindowGroup( iRwSession );	
       
   145     
       
   146 	User::LeaveIfError( iRwGroup->Construct( groupId, EFalse ) );	
       
   147     iRwGroup->SetName( KMccWindowGroupName );
       
   148     
       
   149     // TBD: use also iWindowOrdinalPriority
       
   150     iRwGroup->SetOrdinalPosition( iSettings.iWindowOrdinalPosition );
       
   151          
       
   152     // Create screen device
       
   153 	iDev = new (ELeave) CWsScreenDevice( iRwSession );
       
   154 	User::LeaveIfError( iDev->Construct( iSettings.iDeviceIndex ) ); 
       
   155 	
       
   156 	// Create window
       
   157 	iRw = new (ELeave) RWindow( iRwSession );
       
   158     
       
   159     User::LeaveIfError( iRw->Construct( *iRwGroup, (TUint32)iRw ) );
       
   160 
       
   161     iRw->SetPosition( iSettings.iLocation );
       
   162     iRw->SetSize( iSettings.iSize );
       
   163     
       
   164     iRw->SetOrdinalPosition( iSettings.iWindowOrdinalPosition );
       
   165         
       
   166 	__V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: creating graphics context ..." )
       
   167     User::LeaveIfError( iDev->CreateContext( iGc ) );
       
   168 	__V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: graphics context created!" )
       
   169     
       
   170       
       
   171     iRw->Activate();
       
   172     
       
   173     iRwSession.Flush();
       
   174     
       
   175     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: creating redraw handler" )
       
   176     
       
   177     iRedrawHandler = CMccRedrawHandler::NewL( iRwSession, *iRw, *iGc );
       
   178     
       
   179     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: created redraw handler" )
       
   180       
   142       
   181     // Videoplayer needs to be created last, otherwise destruction
   143     // Videoplayer needs to be created last, otherwise destruction
   182     // order causes problems
   144     // order causes problems
   183     iVideoPlayer = CVideoPlayerUtility2::NewL( 
   145     iVideoPlayer = CVideoPlayerUtility2::NewL( 
   184             *this,
   146             *this,
   243 		Stop();
   205 		Stop();
   244 		iVideoPlayer->Close();	
   206 		iVideoPlayer->Close();	
   245 		}
   207 		}
   246 		
   208 		
   247 	delete iVideoPlayer;
   209 	delete iVideoPlayer;
       
   210 	iVideoPlayer = NULL;
   248 	
   211 	
   249 	delete iRedrawHandler;
   212 	DeleteWindowingElements();
   250 	
   213 
   251 	delete iGc;
       
   252 	delete iDev;
       
   253 
       
   254     delete iRw;
       
   255     delete iRwGroup;	
       
   256 	iRwSession.Close();
   214 	iRwSession.Close();
   257 
   215 
   258 	delete iServerName;
   216 	delete iServerName;
   259 	
   217 	
   260 	delete iSearchTermUser;
   218 	delete iSearchTermUser;
   417             {
   375             {
   418             SendStreamEventToClient( KMccStreamResumed, iCurrentUser );
   376             SendStreamEventToClient( KMccStreamResumed, iCurrentUser );
   419             }
   377             }
   420         else
   378         else
   421             {
   379             {
   422             iRedrawHandler->BlackDrawingL( ETrue );
       
   423             SendStreamEventToClient( KMccStreamStarted, iCurrentUser );
   380             SendStreamEventToClient( KMccStreamStarted, iCurrentUser );
   424             SetStartedOnce( userEntry, ETrue );
   381             SetStartedOnce( userEntry, ETrue );
   425             }   
   382             }   
   426         }
   383         }
   427   
   384   
   775 
   732 
   776 	if ( AnalyzeTimeStampL( user, aHeaderInfo ) &&
   733 	if ( AnalyzeTimeStampL( user, aHeaderInfo ) &&
   777 	     user.PacketOverflowState() != CMccVideoSinkUser::EOccured && 
   734 	     user.PacketOverflowState() != CMccVideoSinkUser::EOccured && 
   778 	     dataSize >= KMccMinPacketSize )
   735 	     dataSize >= KMccMinPacketSize )
   779 		{
   736 		{
   780 		iRedrawHandler->BlackDrawingL( EFalse );
       
   781 		
       
   782     	__V_SOURCESINK_CONTROLL( 
   737     	__V_SOURCESINK_CONTROLL( 
   783     	    "CMccVideoSinkImpl::EmptyBufferL, sending packet to helix" )		
   738     	    "CMccVideoSinkImpl::EmptyBufferL, sending packet to helix" )		
   784       
   739       
   785         CMccVideoJitterBuffer::TMccPacketBufferingStatus bufferingStatus =
   740         CMccVideoJitterBuffer::TMccPacketBufferingStatus bufferingStatus =
   786             user.EnqueueL( aHeaderInfo, buf->Data() );
   741             user.EnqueueL( aHeaderInfo, buf->Data() );
   835         __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl window ordinal priority:", 
   790         __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl window ordinal priority:", 
   836                 aSettings.iWindowOrdinalPriority )
   791                 aSettings.iWindowOrdinalPriority )
   837         __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl rotation:", 
   792         __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl rotation:", 
   838                 aSettings.iRotation )
   793                 aSettings.iRotation )
   839         
   794         
   840         __ASSERT_ALWAYS( iRw && iRwGroup && iDev, User::Leave( KErrNotReady ) );
   795         // Need to recreate windowing stuff, otherwise orientation switch does not work
   841         
   796         DeleteWindowingElements();
   842         // TBD: use also aSettings.iWindowOrdinalPriority
   797         CreateWindowingElementsL(aSettings);
   843         iRwGroup->SetOrdinalPosition( aSettings.iWindowOrdinalPosition );
   798         
   844 
   799         UpdateScreenTransparencyL(aSettings);
   845         iRw->SetPosition( aSettings.iLocation );
       
   846         iRw->SetSize( aSettings.iSize );
       
   847         iRw->SetOrdinalPosition( aSettings.iWindowOrdinalPosition );
       
   848         
       
   849         iRwSession.Flush();
       
   850             
   800             
   851         SetDisplayWindowL( iRwSession, *iDev, *iRw );
   801         SetDisplayWindowL( iRwSession, *iDev, *iRw );
   852         
   802         
   853         SetRotationL( aSettings.iRotation, aForceUpdate );
   803         SetRotationL( aSettings.iRotation, aForceUpdate );
   854         
   804         
  1944             allUsersReady = EFalse;
  1894             allUsersReady = EFalse;
  1945             }
  1895             }
  1946         }
  1896         }
  1947     return allUsersReady;
  1897     return allUsersReady;
  1948     }
  1898     }
       
  1899 
       
  1900 // ---------------------------------------------------------------------------
       
  1901 //
       
  1902 // ---------------------------------------------------------------------------
       
  1903 // 
       
  1904 void CMccVideoSinkImpl::UpdateScreenTransparencyL(const TMccVideoSinkSetting& aSettings)
       
  1905     {
       
  1906     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::UpdateScreenTransparencyL" )
       
  1907     __ASSERT_ALWAYS( iGc && iRw, User::Leave( KErrNotReady ) );
       
  1908     TRect vfRect( TPoint( 0, 0 ), aSettings.iSize );
       
  1909     iGc->Activate( *iRw ); 
       
  1910     iRw->Invalidate( vfRect );
       
  1911     iRw->BeginRedraw( vfRect );
       
  1912     iGc->CancelClippingRect();
       
  1913     iGc->SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
       
  1914     iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  1915     iGc->SetBrushColor( TRgb( 0, 0, 0, 0 ) );
       
  1916     iGc->DrawRect( vfRect );
       
  1917     iRw->EndRedraw();
       
  1918     iGc->Deactivate();
       
  1919     iRwSession.Flush();
       
  1920     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::UpdateScreenTransparencyL, exit" )
       
  1921     }
       
  1922 
       
  1923 // ---------------------------------------------------------------------------
       
  1924 //
       
  1925 // ---------------------------------------------------------------------------
       
  1926 //
       
  1927 void CMccVideoSinkImpl::DeleteWindowingElements()
       
  1928     {
       
  1929     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::DeleteWindowingElements" )
       
  1930     if ( iVideoPlayer && iRw )
       
  1931         {
       
  1932         __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: removing window from player" )
       
  1933         iVideoPlayer->RemoveDisplayWindow( *iRw );
       
  1934         }
       
  1935     delete iGc;
       
  1936     iGc = NULL;
       
  1937     delete iDev;
       
  1938     iDev = NULL;
       
  1939     delete iRw;
       
  1940     iRw = NULL;
       
  1941     delete iRwGroup;    
       
  1942     iRwGroup = NULL;
       
  1943     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::DeleteWindowingElements, exit" )
       
  1944     }
       
  1945 
       
  1946 // ---------------------------------------------------------------------------
       
  1947 //
       
  1948 // ---------------------------------------------------------------------------
       
  1949 //
       
  1950 void CMccVideoSinkImpl::CreateWindowingElementsL(const TMccVideoSinkSetting& aSettings)
       
  1951     {
       
  1952     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::CreateWindowingElementsL" )
       
  1953         
       
  1954     __ASSERT_ALWAYS( !iGc && !iDev && !iRw && !iRwGroup, User::Leave( KErrAlreadyExists ) );
       
  1955         
       
  1956     TInt groupId = iRwSession.GetFocusWindowGroup();
       
  1957     iRwGroup = new (ELeave) RWindowGroup( iRwSession ); 
       
  1958     
       
  1959     User::LeaveIfError( iRwGroup->Construct( groupId, EFalse ) );   
       
  1960     iRwGroup->SetName( KMccWindowGroupName );
       
  1961     
       
  1962     // TBD: use also iWindowOrdinalPriority
       
  1963     iRwGroup->SetOrdinalPosition( aSettings.iWindowOrdinalPosition );
       
  1964     iRwGroup->AutoForeground( EFalse );
       
  1965        
       
  1966     // Create screen device
       
  1967     iDev = new (ELeave) CWsScreenDevice( iRwSession );
       
  1968     User::LeaveIfError( iDev->Construct( aSettings.iDeviceIndex ) ); 
       
  1969     
       
  1970     // Create window
       
  1971     iRw = new (ELeave) RWindow( iRwSession );
       
  1972 
       
  1973     User::LeaveIfError( iRw->Construct( *iRwGroup, (TUint32)iRw ) );
       
  1974     
       
  1975     iRw->SetPosition( aSettings.iLocation );
       
  1976     iRw->SetSize( aSettings.iSize );
       
  1977     
       
  1978     iRw->SetOrdinalPosition( aSettings.iWindowOrdinalPosition );
       
  1979       
       
  1980     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: creating graphics context ..." )
       
  1981     User::LeaveIfError( iDev->CreateContext( iGc ) );
       
  1982     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: graphics context created!" )   
       
  1983     
       
  1984     iRw->Activate();
       
  1985     
       
  1986     iRwSession.Flush();
       
  1987     
       
  1988     __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::CreateWindowingElementsL, exit" )
       
  1989     }
  1949     
  1990     
  1950 // End of file
  1991 // End of file
  1951 
  1992