os/mm/mmplugins/mmfwplugins/src/Plugin/Controller/Video/AviPlayController/srtreader.cpp
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include "srtreader.h"
21 /** Default constructor */
22 CSrtReader::CSrtReader()
26 /** Allocates and constructs a srt subtitle source
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.
32 CSrtReader* CSrtReader::NewL(const TDesC& aFilePath)
34 CSrtReader* self = new(ELeave) CSrtReader();
35 CleanupStack::PushL(self);
36 self->ConstructL(aFilePath);
37 CleanupStack::Pop(self);
41 /** Initialises the srt reader
43 @leave If an error occurs, the method will leave with a system-wide error code.
45 void CSrtReader::ConstructL(const TDesC& aFilePath)
47 if (aFilePath.Length() < 1)
49 User::Leave(KErrArgument);
52 User::LeaveIfError(iFsSession.Connect());
54 if (BaflUtils::FileExists(iFsSession, aFilePath))
56 User::LeaveIfError(iSource.Open(iFsSession, aFilePath, EFileRead));
60 User::Leave(KErrNotFound);
65 CSrtReader::~CSrtReader()
71 void CSrtReader::GetSupportedSubtitleLanguagesL(RArray<TLanguage>& /*aLanguages*/)
73 User::Leave(KErrNotSupported);
76 TLanguage CSrtReader::SubtitleLanguageL()
78 User::Leave(KErrNotSupported);
82 void CSrtReader::SetSubtitleLanguageL(TLanguage /*aLanguage*/)
84 User::Leave(KErrNotSupported);
87 TInt CSrtReader::SetPosition(TInt aPosition)
89 return iSource.Seek(ESeekStart, aPosition);
92 TInt CSrtReader::GetBuffer(TDes8& aBuffer)
95 TInt bufLen = aBuffer.MaxLength();
102 err = iSource.Read(aBuffer);
106 if (0 == aBuffer.Length())