Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Unified Diff: third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp

Issue 1570263002: MediaRecorder: make EventListener and stop if receiving on{add,remove}track from WebMediaStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp
diff --git a/third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp b/third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp
index 9713746b3413c61ba99626773af403ac7249b3eb..98974732a7f778d09cc99b766fe2d16a27afbc4f 100644
--- a/third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp
+++ b/third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp
@@ -36,6 +36,33 @@ String stateToString(MediaRecorder::State state)
} // namespace
+class MediaRecorder::TrackEventListener final : public EventListener {
+public:
+ static PassRefPtrWillBeRawPtr<TrackEventListener> create(blink::WebMediaRecorderHandlerClient* client)
+ {
+ return adoptRefWillBeNoop(new TrackEventListener(client));
+ }
+
+ bool operator==(const EventListener& other) const override
+ {
+ return this == &other;
+ }
+
+private:
+ TrackEventListener(blink::WebMediaRecorderHandlerClient* client)
+ : EventListener(JSEventListenerType)
+ , m_client(client)
+ {
+ }
+
+ void handleEvent(ExecutionContext* executionContext, Event*) override
+ {
+ m_client->onError("MediaStream got a Track added/removed");
+ }
+
+ blink::WebMediaRecorderHandlerClient* const m_client;
+};
+
MediaRecorder* MediaRecorder::create(ExecutionContext* context, MediaStream* stream, ExceptionState& exceptionState)
{
MediaRecorder* recorder = new MediaRecorder(context, stream, MediaRecorderOptions(), exceptionState);
@@ -76,6 +103,11 @@ MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, con
exceptionState.throwDOMException(NotSupportedError, "Failed to initialize native MediaRecorder, the type provided " + m_mimeType + "is unsupported." );
return;
}
+
+ m_addOrRemoveTrackListener = TrackEventListener::create(this);
+ stream->addEventListener(EventTypeNames::addtrack, m_addOrRemoveTrackListener, false);
+ stream->addEventListener(EventTypeNames::removetrack, m_addOrRemoveTrackListener, false);
+
m_stopped = false;
}

Powered by Google App Engine
This is Rietveld 408576698