Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / cdm / ppapi / external_clear_key / cdm_video_decoder.cc
blob297ea844918d223d13361c4deb90b464de92c6c7
1 // Copyright 2013 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.
5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "media/cdm/ppapi/external_clear_key/cdm_video_decoder.h"
9 #if defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER)
10 #include "media/cdm/ppapi/external_clear_key/fake_cdm_video_decoder.h"
11 #endif
13 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
14 #include "media/cdm/ppapi/external_clear_key/ffmpeg_cdm_video_decoder.h"
15 #endif
17 #if defined(CLEAR_KEY_CDM_USE_LIBVPX_DECODER)
18 #include "media/cdm/ppapi/external_clear_key/libvpx_cdm_video_decoder.h"
19 #endif
21 namespace media {
23 scoped_ptr<CdmVideoDecoder> CreateVideoDecoder(
24 ClearKeyCdmHost* host, const cdm::VideoDecoderConfig& config) {
25 scoped_ptr<CdmVideoDecoder> video_decoder;
26 #if defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER)
27 video_decoder.reset(new FakeCdmVideoDecoder(host));
29 if (!video_decoder->Initialize(config))
30 video_decoder.reset();
31 #else
33 #if defined(CLEAR_KEY_CDM_USE_LIBVPX_DECODER)
34 if (config.codec == cdm::VideoDecoderConfig::kCodecVp8 ||
35 config.codec == cdm::VideoDecoderConfig::kCodecVp9) {
36 video_decoder.reset(new LibvpxCdmVideoDecoder(host));
38 if (!video_decoder->Initialize(config))
39 video_decoder.reset();
41 return video_decoder.Pass();
43 #endif
45 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
46 video_decoder.reset(new FFmpegCdmVideoDecoder(host));
48 if (!video_decoder->Initialize(config))
49 video_decoder.reset();
50 #endif
52 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER
54 return video_decoder.Pass();
57 } // namespace media