| 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_
|
|
|