• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The libgav1 Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIBGAV1_EXAMPLES_FILE_READER_INTERFACE_H_
18 #define LIBGAV1_EXAMPLES_FILE_READER_INTERFACE_H_
19 
20 #include <cstddef>
21 #include <cstdint>
22 #include <vector>
23 
24 namespace libgav1 {
25 
26 class FileReaderInterface {
27  public:
28   FileReaderInterface() = default;
29   FileReaderInterface(const FileReaderInterface&) = delete;
30   FileReaderInterface& operator=(const FileReaderInterface&) = delete;
31 
32   FileReaderInterface(FileReaderInterface&&) = default;
33   FileReaderInterface& operator=(FileReaderInterface&&) = default;
34 
35   // Closes the file.
36   virtual ~FileReaderInterface() = default;
37 
38   // Reads a temporal unit from the file and writes the data to |tu_data|.
39   // Returns true when:
40   // - A temporal unit is read successfully, or
41   // - At end of file.
42   // When ReadTemporalUnit() is called at the end of the file, it will return
43   // true without writing any data to |tu_data|.
44   //
45   // The |timestamp| pointer is optional: callers not interested in timestamps
46   // can pass nullptr. When |timestamp| is not a nullptr, this function returns
47   // the presentation timestamp of the temporal unit.
48   /*LIBGAV1_MUST_USE_RESULT*/ virtual bool ReadTemporalUnit(
49       std::vector<uint8_t>* tu_data, int64_t* timestamp) = 0;
50 
51   /*LIBGAV1_MUST_USE_RESULT*/ virtual bool IsEndOfFile() const = 0;
52 
53   // The values returned by these accessors are strictly informative. No
54   // validation is performed when they are read from file.
55   virtual size_t width() const = 0;
56   virtual size_t height() const = 0;
57   virtual size_t frame_rate() const = 0;
58   virtual size_t time_scale() const = 0;
59 };
60 
61 }  // namespace libgav1
62 
63 #endif  // LIBGAV1_EXAMPLES_FILE_READER_INTERFACE_H_
64