1*103e46e4SHarish Mahendrakar // Copyright (c) 2012 The WebM project authors. All Rights Reserved. 2*103e46e4SHarish Mahendrakar // 3*103e46e4SHarish Mahendrakar // Use of this source code is governed by a BSD-style license 4*103e46e4SHarish Mahendrakar // that can be found in the LICENSE file in the root of the source 5*103e46e4SHarish Mahendrakar // tree. An additional intellectual property rights grant can be found 6*103e46e4SHarish Mahendrakar // in the file PATENTS. All contributing project authors may 7*103e46e4SHarish Mahendrakar // be found in the AUTHORS file in the root of the source tree. 8*103e46e4SHarish Mahendrakar 9*103e46e4SHarish Mahendrakar #ifndef WEBVTT_VTTREADER_H_ 10*103e46e4SHarish Mahendrakar #define WEBVTT_VTTREADER_H_ 11*103e46e4SHarish Mahendrakar 12*103e46e4SHarish Mahendrakar #include <cstdio> 13*103e46e4SHarish Mahendrakar #include "./webvttparser.h" 14*103e46e4SHarish Mahendrakar 15*103e46e4SHarish Mahendrakar namespace libwebvtt { 16*103e46e4SHarish Mahendrakar 17*103e46e4SHarish Mahendrakar class VttReader : public libwebvtt::Reader { 18*103e46e4SHarish Mahendrakar public: 19*103e46e4SHarish Mahendrakar VttReader(); 20*103e46e4SHarish Mahendrakar virtual ~VttReader(); 21*103e46e4SHarish Mahendrakar 22*103e46e4SHarish Mahendrakar // Open the file identified by |filename| in read-only mode, as a 23*103e46e4SHarish Mahendrakar // binary stream of bytes. Returns 0 on success, negative if error. 24*103e46e4SHarish Mahendrakar int Open(const char* filename); 25*103e46e4SHarish Mahendrakar 26*103e46e4SHarish Mahendrakar // Closes the file stream. Note that the stream is automatically 27*103e46e4SHarish Mahendrakar // closed when the VttReader object is destroyed. 28*103e46e4SHarish Mahendrakar void Close(); 29*103e46e4SHarish Mahendrakar 30*103e46e4SHarish Mahendrakar // Reads the next character in the file stream, as per the semantics 31*103e46e4SHarish Mahendrakar // of Reader::GetChar. Returns negative if error, 0 on success, and 32*103e46e4SHarish Mahendrakar // positive if end-of-stream has been reached. 33*103e46e4SHarish Mahendrakar virtual int GetChar(char* c); 34*103e46e4SHarish Mahendrakar 35*103e46e4SHarish Mahendrakar private: 36*103e46e4SHarish Mahendrakar FILE* file_; 37*103e46e4SHarish Mahendrakar 38*103e46e4SHarish Mahendrakar VttReader(const VttReader&); 39*103e46e4SHarish Mahendrakar VttReader& operator=(const VttReader&); 40*103e46e4SHarish Mahendrakar }; 41*103e46e4SHarish Mahendrakar 42*103e46e4SHarish Mahendrakar } // namespace libwebvtt 43*103e46e4SHarish Mahendrakar 44*103e46e4SHarish Mahendrakar #endif // WEBVTT_VTTREADER_H_ 45