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

Unified Diff: services/media/framework_ffmpeg/ffmpeg_decoder.cc

Issue 1686363002: Motown: ffmpeg implementations of framework 'parts' (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Changed the way AVBuffer allocation/deallocation is done in the ffmpeg audio decoder. Created 4 years, 10 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/ffmpeg_decoder.cc
diff --git a/services/media/framework_ffmpeg/ffmpeg_decoder.cc b/services/media/framework_ffmpeg/ffmpeg_decoder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f99dc5f90398bb7f14d1154b62bd0262ee6624ac
--- /dev/null
+++ b/services/media/framework_ffmpeg/ffmpeg_decoder.cc
@@ -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.
+
+#include "services/media/framework_ffmpeg/ffmpeg_audio_decoder.h"
+#include "services/media/framework_ffmpeg/ffmpeg_decoder.h"
+#include "services/media/framework_ffmpeg/ffmpeg_type_converters.h"
+#include "services/media/framework_ffmpeg/ffmpeg_video_decoder.h"
+
+namespace mojo {
+namespace media {
+
+Result FfmpegDecoder::Create(
+ const StreamType& stream_type,
+ std::shared_ptr<Decoder>* decoder_out) {
+ DCHECK(decoder_out);
+
+ AvCodecContextPtr av_codec_context(AVCodecContextFromStreamType(stream_type));
+ if (!av_codec_context) {
+ return Result::kUnsupportedOperation;
+ }
+
+ AVCodec* ffmpeg_decoder = avcodec_find_decoder(av_codec_context->codec_id);
+ if (ffmpeg_decoder == nullptr) {
+ return Result::kUnsupportedOperation;
+ }
+
+ int r = avcodec_open2(av_codec_context.get(), ffmpeg_decoder, nullptr);
+ if (r < 0) {
+ return Result::kUnknownError;
+ }
+
+ switch (av_codec_context->codec_type) {
+ case AVMEDIA_TYPE_AUDIO:
+ *decoder_out = std::shared_ptr<Decoder>(
+ new FfmpegAudioDecoder(std::move(av_codec_context)));
+ break;
+ case AVMEDIA_TYPE_VIDEO:
+ *decoder_out = std::shared_ptr<Decoder>(
+ new FfmpegVideoDecoder(std::move(av_codec_context)));
+ break;
+ default:
+ return Result::kUnsupportedOperation;
+ }
+
+ return Result::kOk;
+}
+
+} // namespace media
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698