| 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_FFMPEG_AV_IO_CONTEXT_H_ |
| 6 #define SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_IO_CONTEXT_H_ |
| 7 |
| 8 #include "services/media/framework/parts/reader.h" |
| 9 extern "C" { |
| 10 #include "third_party/ffmpeg/libavformat/avio.h" |
| 11 } |
| 12 |
| 13 namespace mojo { |
| 14 namespace media { |
| 15 |
| 16 struct AVIOContextDeleter { |
| 17 void operator()(AVIOContext* context) const; |
| 18 }; |
| 19 |
| 20 using AvIoContextPtr = std::unique_ptr<AVIOContext, AVIOContextDeleter>; |
| 21 |
| 22 struct AvIoContext { |
| 23 // Creates an ffmpeg avio_context for a given reader. |
| 24 static AvIoContextPtr Create(std::shared_ptr<Reader> reader); |
| 25 |
| 26 // Performs a read operation using the signature required for avio. |
| 27 static int Read(void* opaque, uint8_t* buf, int buf_size); |
| 28 |
| 29 // Performs a seek operation using the signature required for avio. |
| 30 static int64_t Seek(void* opaque, int64_t offset, int whence); |
| 31 |
| 32 ~AvIoContext(); |
| 33 |
| 34 private: |
| 35 AvIoContext(std::shared_ptr<Reader> reader); |
| 36 |
| 37 int Read(uint8_t* buffer, size_t bytes_to_read); |
| 38 |
| 39 int64_t Seek(int64_t offset, int whence); |
| 40 |
| 41 std::shared_ptr<Reader> reader_; |
| 42 bool can_seek_; |
| 43 int64_t size_; |
| 44 int64_t position_ = 0; |
| 45 }; |
| 46 |
| 47 } // namespace media |
| 48 } // namespace mojo |
| 49 |
| 50 #endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_IO_CONTEXT_H_ |
| OLD | NEW |