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

Side by Side Diff: services/media/framework_ffmpeg/ffmpeg_decoder.cc

Issue 1923763002: Motown: Ffmpeg video decoder (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Minor fixes per feedback. Created 4 years, 7 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/media/framework_ffmpeg/av_codec_context.h" 5 #include "services/media/framework_ffmpeg/av_codec_context.h"
6 #include "services/media/framework_ffmpeg/ffmpeg_audio_decoder.h" 6 #include "services/media/framework_ffmpeg/ffmpeg_audio_decoder.h"
7 #include "services/media/framework_ffmpeg/ffmpeg_decoder.h" 7 #include "services/media/framework_ffmpeg/ffmpeg_decoder.h"
8 #include "services/media/framework_ffmpeg/ffmpeg_video_decoder.h" 8 #include "services/media/framework_ffmpeg/ffmpeg_video_decoder.h"
9 9
10 namespace mojo { 10 namespace mojo {
11 namespace media { 11 namespace media {
12 12
13 Result FfmpegDecoder::Create(const StreamType& stream_type, 13 Result FfmpegDecoder::Create(const StreamType& stream_type,
14 std::shared_ptr<Decoder>* decoder_out) { 14 std::shared_ptr<Decoder>* decoder_out) {
15 DCHECK(decoder_out); 15 DCHECK(decoder_out);
16 16
17 AvCodecContextPtr av_codec_context(AvCodecContext::Create(stream_type)); 17 AvCodecContextPtr av_codec_context(AvCodecContext::Create(stream_type));
18 if (!av_codec_context) { 18 if (!av_codec_context) {
19 LOG(ERROR) << "couldn't create codec context";
19 return Result::kUnsupportedOperation; 20 return Result::kUnsupportedOperation;
20 } 21 }
21 22
22 AVCodec* ffmpeg_decoder = avcodec_find_decoder(av_codec_context->codec_id); 23 AVCodec* ffmpeg_decoder = avcodec_find_decoder(av_codec_context->codec_id);
23 if (ffmpeg_decoder == nullptr) { 24 if (ffmpeg_decoder == nullptr) {
25 LOG(ERROR) << "couldn't find decoder context";
24 return Result::kUnsupportedOperation; 26 return Result::kUnsupportedOperation;
25 } 27 }
26 28
27 int r = avcodec_open2(av_codec_context.get(), ffmpeg_decoder, nullptr); 29 int r = avcodec_open2(av_codec_context.get(), ffmpeg_decoder, nullptr);
28 if (r < 0) { 30 if (r < 0) {
31 LOG(ERROR) << "couldn't open the decoder " << r;
29 return Result::kUnknownError; 32 return Result::kUnknownError;
30 } 33 }
31 34
32 switch (av_codec_context->codec_type) { 35 switch (av_codec_context->codec_type) {
33 case AVMEDIA_TYPE_AUDIO: 36 case AVMEDIA_TYPE_AUDIO:
34 *decoder_out = std::shared_ptr<Decoder>( 37 *decoder_out = std::shared_ptr<Decoder>(
35 new FfmpegAudioDecoder(std::move(av_codec_context))); 38 new FfmpegAudioDecoder(std::move(av_codec_context)));
36 break; 39 break;
37 case AVMEDIA_TYPE_VIDEO: 40 case AVMEDIA_TYPE_VIDEO:
38 *decoder_out = std::shared_ptr<Decoder>( 41 *decoder_out = std::shared_ptr<Decoder>(
39 new FfmpegVideoDecoder(std::move(av_codec_context))); 42 new FfmpegVideoDecoder(std::move(av_codec_context)));
40 break; 43 break;
41 default: 44 default:
45 LOG(ERROR) << "unsupported codec type " << av_codec_context->codec_type;
42 return Result::kUnsupportedOperation; 46 return Result::kUnsupportedOperation;
43 } 47 }
44 48
45 return Result::kOk; 49 return Result::kOk;
46 } 50 }
47 51
48 } // namespace media 52 } // namespace media
49 } // namespace mojo 53 } // namespace mojo
OLDNEW
« no previous file with comments | « services/media/framework_ffmpeg/ffmpeg_audio_decoder.cc ('k') | services/media/framework_ffmpeg/ffmpeg_decoder_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698