OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SERVICES_MEDIA_FRAMEWORK_PARTS_READER_H_ | |
6 #define SERVICES_MEDIA_FRAMEWORK_PARTS_READER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "services/media/framework/result.h" | |
11 #include "url/gurl.h" | |
12 | |
13 namespace mojo { | |
14 namespace media { | |
15 | |
16 class Reader; | |
17 | |
18 typedef std::shared_ptr<Reader> ReaderPtr; | |
19 | |
20 // Abstract base class for objects that read raw data on behalf of demuxes. | |
21 // This model is synchronous, because that's how ffmpeg works. | |
jeffbrown
2016/02/02 05:35:48
Is ffmpeg going to be the only client of this inte
dalesat
2016/02/02 21:46:40
I agree. There are comments to this effect elsewhe
| |
22 class Reader { | |
23 public: | |
24 // Creates a Reader object for a given url. | |
25 static Result Create(const GURL& gurl, ReaderPtr* reader_out); | |
26 | |
27 virtual ~Reader() {} | |
28 | |
29 // Initializes the reader. | |
30 virtual Result Init(const GURL& gurl) = 0; | |
31 | |
32 // Reads the given number of bytes into the buffer and returns the number of | |
33 // bytes read. Returns -1 if the operation fails. | |
34 virtual int Read(uint8* buffer, int bytes_to_read) = 0; | |
jeffbrown
2016/02/02 05:35:48
Use size_t or ssize_t for buffer sizes, etc.
dalesat
2016/02/02 21:46:40
Done in another CL.
| |
35 | |
36 // Gets the current position or -1 if the operation fails. | |
37 virtual int64 GetPosition() const = 0; | |
jeffbrown
2016/02/02 05:35:48
Don't you mean int64_t?
dalesat
2016/02/02 21:46:40
Yes. Done.
| |
38 | |
39 // Seeks to the given position and returns it. Returns -1 if the operation | |
40 // fails. | |
41 virtual int64 SetPosition(int64 position) = 0; | |
42 | |
43 // Returns the file size. Returns -1 if the operation fails. | |
44 virtual int64 GetSize() const = 0; | |
jeffbrown
2016/02/02 05:35:48
What if the size isn't known?
dalesat
2016/02/02 21:46:40
Added to comment.
| |
45 | |
46 // Returns true if this object supports seeking, false otherwise. | |
47 virtual bool CanSeek() const = 0; | |
48 }; | |
49 | |
50 } // namespace media | |
51 } // namespace mojo | |
52 | |
53 #endif // MOJO_SERVICES_MEDIA_READER_H_ | |
OLD | NEW |