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

Side by Side 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, 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 #include "services/media/framework_ffmpeg/ffmpeg_audio_decoder.h"
6 #include "services/media/framework_ffmpeg/ffmpeg_decoder.h"
7 #include "services/media/framework_ffmpeg/ffmpeg_type_converters.h"
8 #include "services/media/framework_ffmpeg/ffmpeg_video_decoder.h"
9
10 namespace mojo {
11 namespace media {
12
13 Result FfmpegDecoder::Create(
14 const StreamType& stream_type,
15 std::shared_ptr<Decoder>* decoder_out) {
16 DCHECK(decoder_out);
17
18 AvCodecContextPtr av_codec_context(AVCodecContextFromStreamType(stream_type));
19 if (!av_codec_context) {
20 return Result::kUnsupportedOperation;
21 }
22
23 AVCodec* ffmpeg_decoder = avcodec_find_decoder(av_codec_context->codec_id);
24 if (ffmpeg_decoder == nullptr) {
25 return Result::kUnsupportedOperation;
26 }
27
28 int r = avcodec_open2(av_codec_context.get(), ffmpeg_decoder, nullptr);
29 if (r < 0) {
30 return Result::kUnknownError;
31 }
32
33 switch (av_codec_context->codec_type) {
34 case AVMEDIA_TYPE_AUDIO:
35 *decoder_out = std::shared_ptr<Decoder>(
36 new FfmpegAudioDecoder(std::move(av_codec_context)));
37 break;
38 case AVMEDIA_TYPE_VIDEO:
39 *decoder_out = std::shared_ptr<Decoder>(
40 new FfmpegVideoDecoder(std::move(av_codec_context)));
41 break;
42 default:
43 return Result::kUnsupportedOperation;
44 }
45
46 return Result::kOk;
47 }
48
49 } // namespace media
50 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698