content/media/directshow/DirectShowDecoder.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/directshow/DirectShowDecoder.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "DirectShowDecoder.h"
    1.11 +#include "DirectShowReader.h"
    1.12 +#include "MediaDecoderStateMachine.h"
    1.13 +#include "mozilla/Preferences.h"
    1.14 +#include "mozilla/WindowsVersion.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +
    1.18 +MediaDecoderStateMachine* DirectShowDecoder::CreateStateMachine()
    1.19 +{
    1.20 +  return new MediaDecoderStateMachine(this, new DirectShowReader(this));
    1.21 +}
    1.22 +
    1.23 +/* static */
    1.24 +bool
    1.25 +DirectShowDecoder::GetSupportedCodecs(const nsACString& aType,
    1.26 +                                      char const *const ** aCodecList)
    1.27 +{
    1.28 +  if (!IsEnabled()) {
    1.29 +    return false;
    1.30 +  }
    1.31 +
    1.32 +  static char const *const mp3AudioCodecs[] = {
    1.33 +    "mp3",
    1.34 +    nullptr
    1.35 +  };
    1.36 +  if (aType.EqualsASCII("audio/mpeg") ||
    1.37 +      aType.EqualsASCII("audio/mp3")) {
    1.38 +    if (aCodecList) {
    1.39 +      *aCodecList = mp3AudioCodecs;
    1.40 +    }
    1.41 +    return true;
    1.42 +  }
    1.43 +
    1.44 +  return false;
    1.45 +}
    1.46 +
    1.47 +/* static */
    1.48 +bool
    1.49 +DirectShowDecoder::IsEnabled()
    1.50 +{
    1.51 +  return Preferences::GetBool("media.directshow.enabled");
    1.52 +}
    1.53 +
    1.54 +DirectShowDecoder::DirectShowDecoder()
    1.55 +{
    1.56 +  MOZ_COUNT_CTOR(DirectShowDecoder);
    1.57 +}
    1.58 +
    1.59 +DirectShowDecoder::~DirectShowDecoder()
    1.60 +{
    1.61 +  MOZ_COUNT_DTOR(DirectShowDecoder);
    1.62 +}
    1.63 +
    1.64 +} // namespace mozilla
    1.65 +

mercurial