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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(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_FORMAT_CONTEXT_H_
6 #define SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_FORMAT_CONTEXT_H_
7
8 #include "services/media/framework_ffmpeg/av_io_context.h"
9 extern "C" {
10 #include "third_party/ffmpeg/libavcodec/avcodec.h"
11 #include "third_party/ffmpeg/libavformat/avformat.h"
12 }
13
14 namespace mojo {
15 namespace media {
16
17 struct AVFormatContextDeleter {
18 inline void operator()(AVFormatContext* ptr) const {
19 avformat_free_context(ptr);
20 }
21 };
22
23 using AvFormatContextPtr =
24 std::unique_ptr<AVFormatContext, AVFormatContextDeleter>;
25
26 struct AvFormatContext {
27 static AvFormatContextPtr OpenInput(const AvIoContextPtr& io_context) {
28 AVFormatContext* format_context = avformat_alloc_context();
29 format_context->flags |= AVFMT_FLAG_CUSTOM_IO | AVFMT_FLAG_FAST_SEEK;
30 format_context->pb = io_context.get();
31
32 // TODO(dalesat): This synchronous operation may take a long time.
33 int r = avformat_open_input(&format_context, nullptr, nullptr, nullptr);
34 if (r < 0) {
35 delete format_context;
36 format_context = nullptr;
37 }
38
39 return AvFormatContextPtr(format_context);
40 }
41 };
42
43 } // namespace media
44 } // namespace mojo
45
46 #endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_FORMAT_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698