Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/wave/WaveDecoder.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 sts=2 et cindent: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "WaveDecoder.h"
8
#include "MediaContainerType.h"
9
#include "MediaDecoder.h"
10
11
namespace mozilla {
12
13
/* static */ bool
14
WaveDecoder::IsSupportedType(const MediaContainerType& aContainerType)
15
0
{
16
0
  if (!MediaDecoder::IsWaveEnabled()) {
17
0
    return false;
18
0
  }
19
0
  if (aContainerType.Type() == MEDIAMIMETYPE("audio/wave") ||
20
0
      aContainerType.Type() == MEDIAMIMETYPE("audio/x-wav") ||
21
0
      aContainerType.Type() == MEDIAMIMETYPE("audio/wav") ||
22
0
      aContainerType.Type() == MEDIAMIMETYPE("audio/x-pn-wav")) {
23
0
    return (aContainerType.ExtendedType().Codecs().IsEmpty() ||
24
0
            aContainerType.ExtendedType().Codecs() == "1" ||
25
0
            aContainerType.ExtendedType().Codecs() == "6" ||
26
0
            aContainerType.ExtendedType().Codecs() == "7");
27
0
  }
28
0
29
0
  return false;
30
0
}
31
32
/* static */ nsTArray<UniquePtr<TrackInfo>>
33
WaveDecoder::GetTracksInfo(const MediaContainerType& aType)
34
0
{
35
0
  nsTArray<UniquePtr<TrackInfo>> tracks;
36
0
  if (!IsSupportedType(aType)) {
37
0
    return tracks;
38
0
  }
39
0
40
0
  const MediaCodecs& codecs = aType.ExtendedType().Codecs();
41
0
  if (codecs.IsEmpty()) {
42
0
    tracks.AppendElement(
43
0
      CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters(
44
0
        NS_LITERAL_CSTRING("audio/x-wav"), aType));
45
0
    return tracks;
46
0
  }
47
0
48
0
  for (const auto& codec : codecs.Range()) {
49
0
    tracks.AppendElement(
50
0
      CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters(
51
0
        NS_LITERAL_CSTRING("audio/wave; codecs=") + NS_ConvertUTF16toUTF8(codec),
52
0
        aType));
53
0
  }
54
0
  return tracks;
55
0
}
56
57
} // namespace mozilla