videoplayback/videohelix/src/mpxvideohelixplayback.cpp
branchRCL_3
changeset 9 5294c000a26d
parent 8 ce5ada96ab30
child 10 112a725ff2c2
equal deleted inserted replaced
8:ce5ada96ab30 9:5294c000a26d
    13 *
    13 *
    14 * Description:  This class plays local video file
    14 * Description:  This class plays local video file
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 12 %
    18 // Version : %version: 14 %
    19 
    19 
    20 
    20 
    21 //
    21 //
    22 //  INCLUDE FILES
    22 //  INCLUDE FILES
    23 //
    23 //
   112     {
   112     {
   113         aFile.Close();
   113         aFile.Close();
   114     }
   114     }
   115 
   115 
   116     TInt err = aFile.Open( iFs, aUri, EFileRead | EFileShareReadersOrWriters );
   116     TInt err = aFile.Open( iFs, aUri, EFileRead | EFileShareReadersOrWriters );
   117     HandleOpenFileHandleL( err );
   117 
       
   118     if ( err != KErrNone )
       
   119     {
       
   120         CheckForStreamingUrlL( aUri );
       
   121     }
   118 }
   122 }
   119 
   123 
   120 //  ----------------------------------------------------------------------------
   124 //  ----------------------------------------------------------------------------
   121 //    Initializes a clip for playback from a file name
   125 //    Initializes a clip for playback from a file name
   122 //  ----------------------------------------------------------------------------
   126 //  ----------------------------------------------------------------------------
   123 //
   127 //
   124 void CMPXVideoHelixPlayback::InitialiseL( const TDesC& aSong )
   128 void CMPXVideoHelixPlayback::InitialiseL( const TDesC& aSong )
   125 {
   129 {
   126     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL()"),
   130     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL()"),
   127                    _L("aSong %S"), &aSong );
   131                   _L("aSong %S"), &aSong );
       
   132     
       
   133     InitialiseWithPositionL( aSong );
       
   134 }
       
   135 
       
   136 
       
   137 //  ----------------------------------------------------------------------------
       
   138 //    Initializes a clip for playback from a file name with position
       
   139 //  ----------------------------------------------------------------------------
       
   140 //
       
   141 void CMPXVideoHelixPlayback::InitialiseWithPositionL( const TDesC& aSong, TInt aPosition )
       
   142 {
       
   143     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL()"),
       
   144                    _L("aSong %S, aPosition %d"), &aSong, aPosition );
   128 
   145 
   129     RFile fileHandle;
   146     RFile fileHandle;
   130 
   147 
   131     CleanupClosePushL( fileHandle );
   148     CleanupClosePushL( fileHandle );
   132 
   149 
   133     MPX_TRAPD( err, OpenFileHandleL( aSong, fileHandle ));
   150     MPX_TRAPD( err, OpenFileHandleL( aSong, fileHandle ));
   134 
   151 
   135     if ( err == KErrNone )
   152     if ( err == KErrNone )
   136     {
   153     {
   137         iVideoPlaybackCtlr->OpenFileL( aSong, fileHandle );
   154         iVideoPlaybackCtlr->OpenFileL( aSong, fileHandle, aPosition ); 
   138     }   
   155     }   
   139 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   156 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   140     else if ( err == KErrTooBig )
   157     else if ( err == KErrTooBig )
   141     {
   158     {
   142         // 
   159         //
   143         // use RFile64 handle
   160         // use RFile64 handle
   144         //
   161         //
   145         RFile64 fileHandle64;
   162         RFile64 fileHandle64;
   146         CleanupClosePushL( fileHandle64 );
   163         CleanupClosePushL( fileHandle64 );
   147         
   164 
   148         MPX_TRAPD( err, OpenFileHandle64L( aSong, fileHandle64 ));
   165         MPX_TRAPD( err, OpenFileHandle64L( aSong, fileHandle64 ));
   149 
   166 
   150         if ( err != KErrNone )
   167         if ( err != KErrNone )
   151         {
   168         {
   152             // Handle error
   169             // Handle error
   153             iVideoPlaybackCtlr->HandleError( err );
   170             iVideoPlaybackCtlr->HandleError( err );
   154         }
   171         }
   155         else
   172         else
   156         {
   173         {
   157             iVideoPlaybackCtlr->OpenFile64L( aSong, fileHandle64 );
   174                 iVideoPlaybackCtlr->OpenFile64L( aSong, fileHandle64, aPosition ); 
   158         }
   175         }
   159         
   176 
   160         CleanupStack::PopAndDestroy(); // fileHandle64        
   177         CleanupStack::PopAndDestroy(); // fileHandle64
   161     }
   178     }
   162 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   179 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   163     else
   180     else
   164     {
   181     {
   165         // Handle error
   182         // Handle error
   166         iVideoPlaybackCtlr->HandleError( err );        
   183         iVideoPlaybackCtlr->HandleError( err );
   167     }
   184     }
       
   185 
       
   186     CleanupStack::PopAndDestroy(); // fileHandle
       
   187 }
       
   188 
       
   189 //  ----------------------------------------------------------------------------
       
   190 //    Initializes a clip for playback from a file handle
       
   191 //  ----------------------------------------------------------------------------
       
   192 //
       
   193 void CMPXVideoHelixPlayback::InitialiseL( RFile& aSong )
       
   194 {
       
   195     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL( RFile )"));
       
   196         
       
   197     InitialiseWithPositionL( aSong );
       
   198 }
       
   199 
       
   200 //  ----------------------------------------------------------------------------
       
   201 //    Initializes a clip for playback from a file handle with position
       
   202 //  ----------------------------------------------------------------------------
       
   203 //
       
   204 void CMPXVideoHelixPlayback::InitialiseWithPositionL( RFile& aSong, TInt aPosition )
       
   205 {
       
   206     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseWithPositionL( RFile )"),
       
   207                    _L("aPosition %d"), aPosition );
   168     
   208     
   169     CleanupStack::PopAndDestroy(); // fileHandle
       
   170 }
       
   171 
       
   172 //  ----------------------------------------------------------------------------
       
   173 //    Initializes a clip for playback from a file handle
       
   174 //  ----------------------------------------------------------------------------
       
   175 //
       
   176 void CMPXVideoHelixPlayback::InitialiseL( RFile& aSong )
       
   177 {
       
   178     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL( RFile )"));
       
   179 
       
   180     TFileName filename;
   209     TFileName filename;
   181     aSong.FullName( filename );
   210     aSong.FullName( filename );
   182 
   211 
   183     iVideoPlaybackCtlr->OpenFileL( filename, aSong );
   212     iVideoPlaybackCtlr->OpenFileL( filename, aSong, aPosition ); 
   184 }
   213 }
   185 
   214 
   186 
   215 
   187 //  ----------------------------------------------------------------------------
   216 //  ----------------------------------------------------------------------------
   188 //    Initializes a clip for playback from a file name
   217 //    Initializes a clip for playback from a file name
   189 //  ----------------------------------------------------------------------------
   218 //  ----------------------------------------------------------------------------
   190 //
   219 //
   191 void CMPXVideoHelixPlayback::InitStreamingL( const TDesC& aUri,
   220 void CMPXVideoHelixPlayback::InitStreamingL( const TDesC& aUri,
   192                                              const TDesC8& /*aType*/,
   221                                              const TDesC8& /*aType*/,
   193                                              TInt aAccessPoint )
   222                                              TInt aAccessPoint, 
       
   223                                              TInt aPosition ) 
   194 {
   224 {
   195     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreamingL()"),
   225     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreamingL()"),
   196                    _L("aUri %S, aAccessPoint %d"), &aUri, aAccessPoint );
   226                    _L("aUri %S, aAccessPoint %d, aPosition %d"), &aUri, aAccessPoint, aPosition );
   197 
   227 
   198     RFile fileHandle;
   228     RFile fileHandle;
   199 
   229 
   200     CleanupClosePushL( fileHandle );
   230     CleanupClosePushL( fileHandle );
   201 
   231 
   206         // Handle error
   236         // Handle error
   207         iVideoPlaybackCtlr->HandleError( err );
   237         iVideoPlaybackCtlr->HandleError( err );
   208     }
   238     }
   209     else
   239     else
   210     {
   240     {
   211         iVideoPlaybackCtlr->OpenFileL( aUri, fileHandle, aAccessPoint );
   241         iVideoPlaybackCtlr->OpenFileL( aUri, fileHandle, aPosition, aAccessPoint );  
   212     }
   242     }
   213 
   243 
   214     CleanupStack::PopAndDestroy();
   244     CleanupStack::PopAndDestroy();
   215 }
   245 }
   216 
   246 
   217 //  ----------------------------------------------------------------------------
   247 //  ----------------------------------------------------------------------------
   218 //    Initializes a clip for playback from a file handle
   248 //    Initializes a clip for playback from a file handle
   219 //  ----------------------------------------------------------------------------
   249 //  ----------------------------------------------------------------------------
   220 //
   250 //
   221 void CMPXVideoHelixPlayback::InitStreamingL( RFile& aFile, TInt aAccessPoint  )
   251 void CMPXVideoHelixPlayback::InitStreamingL( RFile& aFile, TInt aAccessPoint, TInt aPosition  ) 
   222 {
   252 {
   223     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreamingL( RFile )"),
   253     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreamingL( RFile )"),
   224                    _L("aAccessPoint = %d"), aAccessPoint );
   254                    _L("aAccessPoint = %d, aPosition = %d"), aAccessPoint, aPosition );
   225 
   255 
   226     TFileName filename;
   256     TFileName filename;
   227     aFile.FullName( filename );
   257     aFile.FullName( filename );
   228 
   258 
   229     iVideoPlaybackCtlr->OpenFileL( filename, aFile, aAccessPoint );
   259     iVideoPlaybackCtlr->OpenFileL( filename, aFile, aPosition, aAccessPoint );
   230 }
   260 }
   231 
   261 
   232 //  ----------------------------------------------------------------------------
   262 //  ----------------------------------------------------------------------------
   233 //    Executes a command on the selected song
   263 //    Executes a command on the selected song
   234 //  ----------------------------------------------------------------------------
   264 //  ----------------------------------------------------------------------------
   314 void CMPXVideoHelixPlayback::CancelRequest()
   344 void CMPXVideoHelixPlayback::CancelRequest()
   315 {
   345 {
   316     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CancelRequest()"));
   346     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CancelRequest()"));
   317 }
   347 }
   318 
   348 
   319 //  ----------------------------------------------------------------------------
   349 //  ------------------------------------------------------------------------------------------------
   320 //    Handle Open File Handle
   350 //    CMPXVideoHelixPlayback::CheckForStreamingUrlL()
   321 //  ----------------------------------------------------------------------------
   351 //  ------------------------------------------------------------------------------------------------
   322 //
   352 //
   323 void CMPXVideoHelixPlayback::HandleOpenFileHandleL( TInt aError )
   353 void CMPXVideoHelixPlayback::CheckForStreamingUrlL( const TDesC& aUri )
   324 {
   354 {
   325     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::HandleOpenFileHandleL()"));
   355     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CMPXVideoHelixPlayback::CheckForStreamingUrlL()"));
   326     
   356 
   327     //
   357     CMediaRecognizer* recognizer = CMediaRecognizer::NewL();
   328     //  Remap KErrNotReady to KErrNotFound, because it is referencing a drive
   358     CleanupStack::PushL( recognizer );
   329     //  that is not existent
   359 
   330     //
   360     if ( ! recognizer->IsValidStreamingPrefix( aUri ) )
   331     if ( aError == KErrNotReady )
   361     {
   332     {
   362         User::LeaveIfError( KErrNotFound );
   333         aError = KErrNotFound;
   363     }
   334     }
   364 
   335     
   365     CleanupStack::PopAndDestroy( recognizer );
   336     MPX_DEBUG(_L("CMPXVideoHelixPlayback::HandleOpenFileHandleL() Open error = %d"), aError);
       
   337     
       
   338     //
       
   339     //  if aSong is an streaming link and contains one of the streaming schemas
       
   340     //  eg. rtsp:// , http:// etc. then a file handle can not be opened
       
   341     //  ignore KErrBadName
       
   342     //
       
   343     if ( aError != KErrBadName )
       
   344     {
       
   345         User::LeaveIfError( aError );
       
   346     }
       
   347 }
   366 }
   348 
   367 
   349 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   368 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   350 
   369 
   351 //  ------------------------------------------------------------------------------------------------
   370 //  ------------------------------------------------------------------------------------------------
   362     {
   381     {
   363         aFile.Close();
   382         aFile.Close();
   364     }
   383     }
   365 
   384 
   366     TInt err = aFile.Open( iFs, aUri, EFileRead | EFileShareReadersOrWriters );
   385     TInt err = aFile.Open( iFs, aUri, EFileRead | EFileShareReadersOrWriters );
   367     HandleOpenFileHandleL( err );
   386 
       
   387     if ( err != KErrNone )
       
   388     {
       
   389         CheckForStreamingUrlL( aUri );
       
   390     }
   368 }
   391 }
   369 
   392 
   370 //  ----------------------------------------------------------------------------
   393 //  ----------------------------------------------------------------------------
   371 //    Initializes a clip for playback from a 64-bit file handle
   394 //    Initializes a clip for playback from a 64-bit file handle
   372 //  ----------------------------------------------------------------------------
   395 //  ----------------------------------------------------------------------------
   373 //
   396 //
   374 void CMPXVideoHelixPlayback::Initialise64L( RFile64& aSong )
   397 void CMPXVideoHelixPlayback::Initialise64L( RFile64& aSong, TInt aPosition ) 
   375 {
   398 {
   376     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::Initialise64L( RFile64 )"));
   399     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::Initialise64L( RFile64 )"),
   377 
   400                    _L("aPosition %d"), aPosition );
   378     TFileName filename;
   401     TFileName filename;
   379     aSong.FullName( filename );
   402     aSong.FullName( filename );
   380 
   403 
   381     iVideoPlaybackCtlr->OpenFile64L( filename, aSong );
   404     iVideoPlaybackCtlr->OpenFile64L( filename, aSong, aPosition );   
   382 }
   405 }
   383 
   406 
   384 //  ----------------------------------------------------------------------------
   407 //  ----------------------------------------------------------------------------
   385 //    Initializes a clip for playback from a 64-bit file handle
   408 //    Initializes a clip for playback from a 64-bit file handle
   386 //  ----------------------------------------------------------------------------
   409 //  ----------------------------------------------------------------------------
   387 //
   410 //
   388 void CMPXVideoHelixPlayback::InitStreaming64L( RFile64& aFile, TInt aAccessPoint  )
   411 void CMPXVideoHelixPlayback::InitStreaming64L( RFile64& aFile, TInt aAccessPoint, TInt aPosition ) 
   389 {
   412 {
   390     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreaming64L( RFile64 )"),
   413     MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreaming64L( RFile64 )"),
   391                    _L("aAccessPoint = %d"), aAccessPoint );
   414                    _L("aAccessPoint = %d, aPosition %d"), aAccessPoint, aPosition );
   392 
   415 
   393     TFileName filename;
   416     TFileName filename;
   394     aFile.FullName( filename );
   417     aFile.FullName( filename );
   395 
   418 
   396     iVideoPlaybackCtlr->OpenFile64L( filename, aFile, aAccessPoint );
   419     iVideoPlaybackCtlr->OpenFile64L( filename, aFile, aPosition, aAccessPoint ); 
   397 }
   420 }
   398 
   421 
   399 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   422 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   400 
   423 
   401 // End of file
   424 // End of file