1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/basictypes.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/scoped_ptr.h"
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "media/cdm/ppapi/external_clear_key/cdm_video_decoder.h"
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER)
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "media/cdm/ppapi/external_clear_key/fake_cdm_video_decoder.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "media/cdm/ppapi/external_clear_key/ffmpeg_cdm_video_decoder.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(CLEAR_KEY_CDM_USE_LIBVPX_DECODER)
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "media/cdm/ppapi/external_clear_key/libvpx_cdm_video_decoder.h"
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
21ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdochnamespace media {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)scoped_ptr<CdmVideoDecoder> CreateVideoDecoder(
24f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    ClearKeyCdmHost* host, const cdm::VideoDecoderConfig& config) {
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<CdmVideoDecoder> video_decoder;
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER)
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  video_decoder.reset(new FakeCdmVideoDecoder(host));
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!video_decoder->Initialize(config))
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    video_decoder.reset();
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(CLEAR_KEY_CDM_USE_LIBVPX_DECODER)
34a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  if (config.codec == cdm::VideoDecoderConfig::kCodecVp8 ||
35a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch      config.codec == cdm::VideoDecoderConfig::kCodecVp9) {
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    video_decoder.reset(new LibvpxCdmVideoDecoder(host));
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if (!video_decoder->Initialize(config))
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      video_decoder.reset();
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return video_decoder.Pass();
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  video_decoder.reset(new FFmpegCdmVideoDecoder(host));
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (!video_decoder->Initialize(config))
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    video_decoder.reset();
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return video_decoder.Pass();
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
57ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch}  // namespace media
58