| 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" | 9 #include "core/html/track/AudioTrackList.h" |
| 10 #include "core/html/track/VideoTrackList.h" | 10 #include "core/html/track/VideoTrackList.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 HTMLMediaElement& element, | 24 HTMLMediaElement& element, |
| 25 ExceptionState& exceptionState) { | 25 ExceptionState& exceptionState) { |
| 26 if (element.currentSrc().isNull()) { | 26 if (element.currentSrc().isNull()) { |
| 27 exceptionState.throwDOMException(NotSupportedError, | 27 exceptionState.throwDOMException(NotSupportedError, |
| 28 "The media element must have a source."); | 28 "The media element must have a source."); |
| 29 return nullptr; | 29 return nullptr; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Avoid capturing from EME-protected Media Elements. | 32 // Avoid capturing from EME-protected Media Elements. |
| 33 if (HTMLMediaElementEncryptedMedia::mediaKeys(element)) { | 33 if (HTMLMediaElementEncryptedMedia::mediaKeys(element)) { |
| 34 // This exception is not defined in the spec, see https://github.com/w3c/med
iacapture-fromelement/issues/20. | 34 // This exception is not defined in the spec, see |
| 35 // https://github.com/w3c/mediacapture-fromelement/issues/20. |
| 35 exceptionState.throwDOMException(NotSupportedError, | 36 exceptionState.throwDOMException(NotSupportedError, |
| 36 "Stream capture not supported with EME"); | 37 "Stream capture not supported with EME"); |
| 37 return nullptr; | 38 return nullptr; |
| 38 } | 39 } |
| 39 | 40 |
| 40 // If |element| is actually playing a MediaStream, just clone it. | 41 // If |element| is actually playing a MediaStream, just clone it. |
| 41 if (HTMLMediaElement::isMediaStreamURL(element.currentSrc().getString())) { | 42 if (HTMLMediaElement::isMediaStreamURL(element.currentSrc().getString())) { |
| 42 return MediaStream::create( | 43 return MediaStream::create( |
| 43 element.getExecutionContext(), | 44 element.getExecutionContext(), |
| 44 MediaStreamRegistry::registry().lookupMediaStreamDescriptor( | 45 MediaStreamRegistry::registry().lookupMediaStreamDescriptor( |
| 45 element.currentSrc().getString())); | 46 element.currentSrc().getString())); |
| 46 } | 47 } |
| 47 | 48 |
| 48 WebMediaStream webStream; | 49 WebMediaStream webStream; |
| 49 webStream.initialize(WebVector<WebMediaStreamTrack>(), | 50 webStream.initialize(WebVector<WebMediaStreamTrack>(), |
| 50 WebVector<WebMediaStreamTrack>()); | 51 WebVector<WebMediaStreamTrack>()); |
| 51 MediaStreamCenter::instance().didCreateMediaStream(webStream); | 52 MediaStreamCenter::instance().didCreateMediaStream(webStream); |
| 52 | 53 |
| 53 if (element.hasVideo()) | 54 if (element.hasVideo()) |
| 54 Platform::current()->createHTMLVideoElementCapturer( | 55 Platform::current()->createHTMLVideoElementCapturer( |
| 55 &webStream, element.webMediaPlayer()); | 56 &webStream, element.webMediaPlayer()); |
| 56 if (element.hasAudio()) | 57 if (element.hasAudio()) |
| 57 Platform::current()->createHTMLAudioElementCapturer( | 58 Platform::current()->createHTMLAudioElementCapturer( |
| 58 &webStream, element.webMediaPlayer()); | 59 &webStream, element.webMediaPlayer()); |
| 59 return MediaStream::create(element.getExecutionContext(), webStream); | 60 return MediaStream::create(element.getExecutionContext(), webStream); |
| 60 } | 61 } |
| 61 | 62 |
| 62 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |