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

Unified Diff: services/media/framework_ffmpeg/av_format_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_format_context.h
diff --git a/services/media/framework_ffmpeg/av_format_context.h b/services/media/framework_ffmpeg/av_format_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..093026bd297f6341b210f79136b467208601edde
--- /dev/null
+++ b/services/media/framework_ffmpeg/av_format_context.h
@@ -0,0 +1,49 @@
+// 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_FORMAT_CONTEXT_H_
+#define SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_FORMAT_CONTEXT_H_
+
+#include "services/media/framework_ffmpeg/av_io_context.h"
+#include "services/media/framework_ffmpeg/ffmpeg_init.h"
+extern "C" {
+#include "third_party/ffmpeg/libavcodec/avcodec.h"
+#include "third_party/ffmpeg/libavformat/avformat.h"
+}
+
+namespace mojo {
+namespace media {
+
+struct AVFormatContextDeleter {
+ inline void operator()(AVFormatContext* ptr) const {
+ avformat_free_context(ptr);
+ }
+};
+
+using AvFormatContextPtr =
+ std::unique_ptr<AVFormatContext, AVFormatContextDeleter>;
+
+struct AvFormatContext {
+ static AvFormatContextPtr OpenInput(const AvIoContextPtr& io_context) {
+ InitFfmpeg();
+
+ AVFormatContext* format_context = avformat_alloc_context();
+ format_context->flags |= AVFMT_FLAG_CUSTOM_IO | AVFMT_FLAG_FAST_SEEK;
+ format_context->pb = io_context.get();
+
+ // TODO(dalesat): This synchronous operation may take a long time.
+ int r = avformat_open_input(&format_context, nullptr, nullptr, nullptr);
+ if (r < 0) {
+ delete format_context;
+ format_context = nullptr;
+ }
+
+ return AvFormatContextPtr(format_context);
+ }
+};
+
+} // namespace media
+} // namespace mojo
+
+#endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_FORMAT_CONTEXT_H_
« no previous file with comments | « services/media/framework_ffmpeg/av_codec_context.cc ('k') | services/media/framework_ffmpeg/av_io_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698