/src/mozilla-central/dom/media/webaudio/MediaElementAudioSourceNode.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 "MediaElementAudioSourceNode.h" |
8 | | #include "mozilla/dom/MediaElementAudioSourceNodeBinding.h" |
9 | | #include "AudioDestinationNode.h" |
10 | | #include "nsIScriptError.h" |
11 | | #include "AudioNodeStream.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext* aContext) |
17 | | : MediaStreamAudioSourceNode(aContext) |
18 | 0 | { |
19 | 0 | } |
20 | | |
21 | | /* static */ already_AddRefed<MediaElementAudioSourceNode> |
22 | | MediaElementAudioSourceNode::Create(AudioContext& aAudioContext, |
23 | | const MediaElementAudioSourceOptions& aOptions, |
24 | | ErrorResult& aRv) |
25 | 0 | { |
26 | 0 | if (aAudioContext.IsOffline()) { |
27 | 0 | aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); |
28 | 0 | return nullptr; |
29 | 0 | } |
30 | 0 | |
31 | 0 | if (aAudioContext.CheckClosed(aRv)) { |
32 | 0 | return nullptr; |
33 | 0 | } |
34 | 0 | |
35 | 0 | RefPtr<MediaElementAudioSourceNode> node = |
36 | 0 | new MediaElementAudioSourceNode(&aAudioContext); |
37 | 0 |
|
38 | 0 | RefPtr<DOMMediaStream> stream = |
39 | 0 | aOptions.mMediaElement->CaptureAudio(aRv, aAudioContext.Destination()->Stream()->Graph()); |
40 | 0 | if (aRv.Failed()) { |
41 | 0 | return nullptr; |
42 | 0 | } |
43 | 0 | |
44 | 0 | node->Init(stream, aRv); |
45 | 0 | if (aRv.Failed()) { |
46 | 0 | return nullptr; |
47 | 0 | } |
48 | 0 | |
49 | 0 | return node.forget(); |
50 | 0 | } |
51 | | |
52 | | JSObject* |
53 | | MediaElementAudioSourceNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
54 | 0 | { |
55 | 0 | return MediaElementAudioSourceNode_Binding::Wrap(aCx, this, aGivenProto); |
56 | 0 | } |
57 | | |
58 | | } // namespace dom |
59 | | } // namespace mozilla |