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