Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: services/media/framework_ffmpeg/av_io_context.h

Issue 1814583002: Motown: New wrapper classes for ffmpeg format context and io context (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Tweaks based on feedback. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/media/framework_ffmpeg/av_io_context.h
diff --git a/services/media/framework_ffmpeg/av_io_context.h b/services/media/framework_ffmpeg/av_io_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..c860318ce2e9a5ddf43e6bd89d576c9f20d99dbd
--- /dev/null
+++ b/services/media/framework_ffmpeg/av_io_context.h
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_IO_CONTEXT_H_
+#define SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_IO_CONTEXT_H_
+
+#include "services/media/framework/parts/reader.h"
+extern "C" {
+#include "third_party/ffmpeg/libavformat/avio.h"
+}
+
+namespace mojo {
+namespace media {
+
+struct AVIOContextDeleter {
+ void operator()(AVIOContext* context) const;
+};
+
+using AvIoContextPtr = std::unique_ptr<AVIOContext, AVIOContextDeleter>;
+
+struct AvIoContext {
+ // Creates an ffmpeg avio_context for a given reader.
+ static AvIoContextPtr Create(std::shared_ptr<Reader> reader);
+
+ // Performs a read operation using the signature required for avio.
+ static int Read(void* opaque, uint8_t* buf, int buf_size);
+
+ // Performs a seek operation using the signature required for avio.
+ static int64_t Seek(void* opaque, int64_t offset, int whence);
+
+ ~AvIoContext();
+
+ private:
+ AvIoContext(std::shared_ptr<Reader> reader);
+
+ int Read(uint8_t* buffer, size_t bytes_to_read);
+
+ int64_t Seek(int64_t offset, int whence);
+
+ std::shared_ptr<Reader> reader_;
+ bool can_seek_;
+ int64_t size_;
+ int64_t position_ = 0;
+};
+
+} // namespace media
+} // namespace mojo
+
+#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_IO_CONTEXT_H_
« no previous file with comments | « services/media/framework_ffmpeg/av_format_context.h ('k') | services/media/framework_ffmpeg/av_io_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698