os/mm/mmplugins/mmfwplugins/src/Plugin/Controller/Video/AviPlayController/srtreader.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-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 #include <e32base.h>
    17 #include <bautils.h> 
    18 
    19 #include "srtreader.h"
    20 
    21 /** Default constructor */
    22 CSrtReader::CSrtReader()
    23     {
    24     }
    25 
    26 /** Allocates and constructs a srt subtitle source 
    27     
    28 @param aFilePath the SRT subtitle file path
    29 @return A pointer to the new object. 
    30 @leave If an error occurs, the method will leave with a system-wide error code. 
    31 */    
    32 CSrtReader* CSrtReader::NewL(const TDesC& aFilePath)
    33     {
    34     CSrtReader* self = new(ELeave) CSrtReader();
    35     CleanupStack::PushL(self);
    36     self->ConstructL(aFilePath);
    37     CleanupStack::Pop(self);
    38     return self;
    39     }
    40 
    41 /** Initialises the srt reader
    42     
    43 @leave If an error occurs, the method will leave with a system-wide error code.
    44 */
    45 void CSrtReader::ConstructL(const TDesC& aFilePath)
    46     {
    47     if (aFilePath.Length() < 1)
    48         {
    49         User::Leave(KErrArgument);
    50         }
    51     
    52     User::LeaveIfError(iFsSession.Connect());
    53     
    54     if (BaflUtils::FileExists(iFsSession, aFilePath))
    55         {
    56         User::LeaveIfError(iSource.Open(iFsSession, aFilePath, EFileRead));
    57         }
    58     else
    59         {
    60         User::Leave(KErrNotFound);
    61         }
    62     } 
    63 
    64 /** Destructor */
    65 CSrtReader::~CSrtReader()
    66     {
    67     iSource.Close();
    68     iFsSession.Close();
    69     }
    70 
    71 void CSrtReader::GetSupportedSubtitleLanguagesL(RArray<TLanguage>& /*aLanguages*/)
    72     {
    73     User::Leave(KErrNotSupported);    
    74     }
    75     
    76 TLanguage CSrtReader::SubtitleLanguageL()
    77     {
    78     User::Leave(KErrNotSupported);
    79     return ELangEnglish;      
    80     }
    81     
    82 void CSrtReader::SetSubtitleLanguageL(TLanguage /*aLanguage*/)
    83     {
    84     User::Leave(KErrNotSupported);  
    85     }
    86 
    87 TInt CSrtReader::SetPosition(TInt aPosition)
    88     {
    89     return iSource.Seek(ESeekStart, aPosition);
    90     }
    91     
    92 TInt CSrtReader::GetBuffer(TDes8& aBuffer)
    93     {
    94     TInt err = KErrNone;
    95     TInt bufLen = aBuffer.MaxLength();
    96     
    97     if (bufLen <= 0)
    98         {
    99         return KErrArgument;
   100         }
   101     
   102     err = iSource.Read(aBuffer);
   103     
   104     if (KErrNone == err)
   105         {
   106         if (0 == aBuffer.Length())
   107             {
   108             err = KErrEof;
   109             }        
   110         }
   111     
   112     return err;
   113     }
   114 
   115 
   116