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" | |
11 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" | 9 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" |
12 #include "modules/encryptedmedia/MediaKeys.h" | 10 #include "modules/encryptedmedia/MediaKeys.h" |
13 #include "modules/mediastream/MediaStream.h" | 11 #include "modules/mediastream/MediaStream.h" |
14 #include "modules/mediastream/MediaStreamRegistry.h" | 12 #include "modules/mediastream/MediaStreamRegistry.h" |
15 #include "platform/mediastream/MediaStreamCenter.h" | 13 #include "platform/mediastream/MediaStreamCenter.h" |
16 #include "public/platform/Platform.h" | 14 #include "public/platform/Platform.h" |
17 #include "public/platform/WebMediaStream.h" | 15 #include "public/platform/WebMediaStream.h" |
18 #include "public/platform/WebMediaStreamTrack.h" | 16 #include "public/platform/WebMediaStreamTrack.h" |
19 | 17 |
20 namespace blink { | 18 namespace blink { |
(...skipping 11 matching lines...) Expand all Loading... |
32 // This exception is not defined in the spec, see https://github.com/w3c
/mediacapture-fromelement/issues/20. | 30 // This exception is not defined in the spec, see https://github.com/w3c
/mediacapture-fromelement/issues/20. |
33 exceptionState.throwDOMException(NotSupportedError, "Stream capture not
supported with EME"); | 31 exceptionState.throwDOMException(NotSupportedError, "Stream capture not
supported with EME"); |
34 return nullptr; | 32 return nullptr; |
35 } | 33 } |
36 | 34 |
37 // If |element| is actually playing a MediaStream, just clone it. | 35 // If |element| is actually playing a MediaStream, just clone it. |
38 if (HTMLMediaElement::isMediaStreamURL(element.currentSrc().getString())) { | 36 if (HTMLMediaElement::isMediaStreamURL(element.currentSrc().getString())) { |
39 return MediaStream::create(element.getExecutionContext(), MediaStreamReg
istry::registry().lookupMediaStreamDescriptor(element.currentSrc().getString()))
; | 37 return MediaStream::create(element.getExecutionContext(), MediaStreamReg
istry::registry().lookupMediaStreamDescriptor(element.currentSrc().getString()))
; |
40 } | 38 } |
41 | 39 |
| 40 // TODO(mcasas): Only <video> tags are supported at the moment. |
| 41 if (element.isHTMLAudioElement()) { |
| 42 NOTIMPLEMENTED(); |
| 43 return nullptr; |
| 44 } |
| 45 |
42 WebMediaStream webStream; | 46 WebMediaStream webStream; |
43 webStream.initialize(WebVector<WebMediaStreamTrack>(), WebVector<WebMediaStr
eamTrack>()); | 47 webStream.initialize(WebVector<WebMediaStreamTrack>(), WebVector<WebMediaStr
eamTrack>()); |
44 MediaStreamCenter::instance().didCreateMediaStream(webStream); | 48 MediaStreamCenter::instance().didCreateMediaStream(webStream); |
45 | 49 |
46 if (element.hasVideo()) | 50 Platform::current()->createHTMLVideoElementCapturer(&webStream, element.webM
ediaPlayer()); |
47 Platform::current()->createHTMLVideoElementCapturer(&webStream, element.
webMediaPlayer()); | |
48 if (element.hasAudio()) | |
49 Platform::current()->createHTMLAudioElementCapturer(&webStream, element.
webMediaPlayer()); | |
50 return MediaStream::create(element.getExecutionContext(), webStream); | 51 return MediaStream::create(element.getExecutionContext(), webStream); |
51 } | 52 } |
52 | 53 |
53 } // namespace blink | 54 } // namespace blink |
OLD | NEW |