OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/mediacapturefromelement/HTMLMediaElementCapture.h" | 5 #include "modules/mediacapturefromelement/HTMLMediaElementCapture.h" |
6 | 6 |
7 #include "core/dom/ExceptionCode.h" | 7 #include "core/dom/ExceptionCode.h" |
8 #include "core/html/HTMLMediaElement.h" | 8 #include "core/html/HTMLMediaElement.h" |
| 9 #include "core/html/track/AudioTrackList.h" |
| 10 #include "core/html/track/VideoTrackList.h" |
9 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" | 11 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" |
10 #include "modules/encryptedmedia/MediaKeys.h" | 12 #include "modules/encryptedmedia/MediaKeys.h" |
11 #include "modules/mediastream/MediaStream.h" | 13 #include "modules/mediastream/MediaStream.h" |
12 #include "modules/mediastream/MediaStreamRegistry.h" | 14 #include "modules/mediastream/MediaStreamRegistry.h" |
13 #include "platform/mediastream/MediaStreamCenter.h" | 15 #include "platform/mediastream/MediaStreamCenter.h" |
14 #include "public/platform/Platform.h" | 16 #include "public/platform/Platform.h" |
15 #include "public/platform/WebMediaStream.h" | 17 #include "public/platform/WebMediaStream.h" |
16 #include "public/platform/WebMediaStreamTrack.h" | 18 #include "public/platform/WebMediaStreamTrack.h" |
17 | 19 |
18 namespace blink { | 20 namespace blink { |
(...skipping 11 matching lines...) Expand all Loading... |
30 // This exception is not defined in the spec, see https://github.com/w3c
/mediacapture-fromelement/issues/20. | 32 // This exception is not defined in the spec, see https://github.com/w3c
/mediacapture-fromelement/issues/20. |
31 exceptionState.throwDOMException(NotSupportedError, "Stream capture not
supported with EME"); | 33 exceptionState.throwDOMException(NotSupportedError, "Stream capture not
supported with EME"); |
32 return nullptr; | 34 return nullptr; |
33 } | 35 } |
34 | 36 |
35 // If |element| is actually playing a MediaStream, just clone it. | 37 // If |element| is actually playing a MediaStream, just clone it. |
36 if (HTMLMediaElement::isMediaStreamURL(element.currentSrc().getString())) { | 38 if (HTMLMediaElement::isMediaStreamURL(element.currentSrc().getString())) { |
37 return MediaStream::create(element.getExecutionContext(), MediaStreamReg
istry::registry().lookupMediaStreamDescriptor(element.currentSrc().getString()))
; | 39 return MediaStream::create(element.getExecutionContext(), MediaStreamReg
istry::registry().lookupMediaStreamDescriptor(element.currentSrc().getString()))
; |
38 } | 40 } |
39 | 41 |
40 // TODO(mcasas): Only <video> tags are supported at the moment. | |
41 if (element.isHTMLAudioElement()) { | |
42 NOTIMPLEMENTED(); | |
43 return nullptr; | |
44 } | |
45 | |
46 WebMediaStream webStream; | 42 WebMediaStream webStream; |
47 webStream.initialize(WebVector<WebMediaStreamTrack>(), WebVector<WebMediaStr
eamTrack>()); | 43 webStream.initialize(WebVector<WebMediaStreamTrack>(), WebVector<WebMediaStr
eamTrack>()); |
48 MediaStreamCenter::instance().didCreateMediaStream(webStream); | 44 MediaStreamCenter::instance().didCreateMediaStream(webStream); |
49 | 45 |
50 Platform::current()->createHTMLVideoElementCapturer(&webStream, element.webM
ediaPlayer()); | 46 if (element.hasVideo()) |
| 47 Platform::current()->createHTMLVideoElementCapturer(&webStream, element.
webMediaPlayer()); |
| 48 if (element.hasAudio()) |
| 49 Platform::current()->createHTMLAudioElementCapturer(&webStream, element.
webMediaPlayer()); |
51 return MediaStream::create(element.getExecutionContext(), webStream); | 50 return MediaStream::create(element.getExecutionContext(), webStream); |
52 } | 51 } |
53 | 52 |
54 } // namespace blink | 53 } // namespace blink |
OLD | NEW |