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

Issue 1543673002: MediaRecorder: make MediaRecorderHandler a MediaStreamObserver (Closed)

Created:
5 years ago by mcasas
Modified:
4 years, 11 months ago
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, Peter Beverloo, mlamouri+watch-test-runner_chromium.org, posciak+watch_chromium.org, jam, avayvod+watch_chromium.org, mcasas+watch_chromium.org, feature-media-reviews_chromium.org, darin-cc_chromium.org, jasonroberts+watch_google.com, mkwst+moarreviews-renderer_chromium.org, xjz+watch_chromium.org, miu+watch_chromium.org, mkwst+moarreviews-shell_chromium.org, isheriff+watch_chromium.org, jochen+watch_chromium.org, imcheng+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

MediaRecorder: make MediaRecorderHandler a MediaStreamObserver MediaRecorderHandler should observe the MediaStream being recorded and stop recording it if the amount of Tracks varies. For that purpose this CL makes MRH a MediaStreamObserver and registers itself during initialize(). MS expects currently that the observer de-register themselves before ~MS(), but that seem to prohibitively peg Observer and Observee lifetime, so that condition is removed. LayoutTests need the WebMediaStream to have at least an empty content/MediaStream, so test_runner/web_test_delegate needs to be updated to rely on a method AddMediaStream implemented in content_shell's BlinkTestRunner to use the content/public/renderer MediaStreamApi :) BUG=545156

Patch Set 1 #

Total comments: 15

Patch Set 2 : perkj@ comments and rebase #

Patch Set 3 : Added content_browsertests for Error Event firing when Track added/removed to MS #

Unified diffs Side-by-side diffs Delta from patch set Stats (+140 lines, -23 lines) Patch
M components/html_viewer/web_test_delegate_impl.h View 1 chunk +1 line, -0 lines 0 comments Download
M components/html_viewer/web_test_delegate_impl.cc View 1 1 chunk +4 lines, -0 lines 0 comments Download
M components/test_runner/mock_web_user_media_client.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M components/test_runner/web_test_delegate.h View 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/media/webrtc_media_recorder_browsertest.cc View 1 2 4 chunks +19 lines, -8 lines 0 comments Download
M content/public/renderer/media_stream_api.h View 1 chunk +3 lines, -0 lines 0 comments Download
M content/public/renderer/media_stream_api.cc View 1 2 chunks +6 lines, -0 lines 0 comments Download
M content/renderer/media/media_recorder_handler.h View 1 2 5 chunks +10 lines, -3 lines 0 comments Download
M content/renderer/media/media_recorder_handler.cc View 1 2 5 chunks +16 lines, -5 lines 0 comments Download
M content/renderer/media/media_stream.h View 1 1 chunk +0 lines, -2 lines 0 comments Download
M content/renderer/media/media_stream.cc View 2 chunks +3 lines, -4 lines 0 comments Download
M content/shell/renderer/layout_test/blink_test_runner.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M content/shell/renderer/layout_test/blink_test_runner.cc View 1 2 chunks +8 lines, -0 lines 0 comments Download
M content/test/data/media/mediarecorder_test.html View 1 2 1 chunk +67 lines, -0 lines 0 comments Download

Messages

Total messages: 16 (7 generated)
mcasas
tommi@/perkj@ PTAL at content/renderer/media/* files (you're more than welcome to PTAL at the rest, too)
5 years ago (2015-12-21 23:58:17 UTC) #4
mcasas
On 2015/12/21 23:58:17, mcasas wrote: > tommi@/perkj@ PTAL at > content/renderer/media/* files > > (you're ...
4 years, 11 months ago (2016-01-07 08:40:21 UTC) #5
mcasas
On 2015/12/21 23:58:17, mcasas wrote: > tommi@/perkj@ PTAL at > content/renderer/media/* files > > (you're ...
4 years, 11 months ago (2016-01-07 08:40:24 UTC) #6
perkj_chrome
It looks like this cl stop the MediaStream if a track is added or removed. ...
4 years, 11 months ago (2016-01-07 09:18:00 UTC) #7
perkj_chrome
Also adding emircan as a reviewer. Please also add a test for this. Do you ...
4 years, 11 months ago (2016-01-07 09:22:59 UTC) #9
mcasas
perkj@ PTAL jochen@: blessing of the small mod in: - components/test_runner/web_test_delegate.h impl in - content/shell/renderer/layout_test/blink_test_runner.{cc,h} ...
4 years, 11 months ago (2016-01-08 00:14:12 UTC) #12
perkj_chrome
A question - why do you need the layout test changes if add a content ...
4 years, 11 months ago (2016-01-08 07:54:50 UTC) #14
mcasas
On 2016/01/08 07:54:50, perkj_chrome wrote: > A question - why do you need the layout ...
4 years, 11 months ago (2016-01-08 18:35:12 UTC) #15
mcasas
4 years, 11 months ago (2016-01-09 02:59:05 UTC) #16
On 2016/01/08 18:35:12, mcasas wrote:
> On 2016/01/08 07:54:50, perkj_chrome wrote:
> > A question - why do you need the layout test changes if add a content
browser
> > test ? 
> > 
> > 
> > layout tests are nice but the problem you hit with MockUserMediaClient does
> not
> > exist if you use a content browser test since they do not use the mock. 
> > 
> > Also the defect your reference is about stopping tracks that are recorded -
> not
> > adding or removing tracks. Will you fix that in a separate cl or is that
> already
> > fixed?
> > 
> >
>
https://codereview.chromium.org/1543673002/diff/1/components/test_runner/mock...
> > File components/test_runner/mock_web_user_media_client.cc (right):
> > 
> >
>
https://codereview.chromium.org/1543673002/diff/1/components/test_runner/mock...
> > components/test_runner/mock_web_user_media_client.cc:166:
> > delegate_->AddMediaStream(&stream);
> > On 2016/01/08 00:14:12, mcasas wrote:
> > > On 2016/01/07 09:18:00, perkj_chrome wrote:
> > > > this seems wrong. Why not just do stream.setExtraData(new
> > > > content::MediaStream()) if you need this.
> > > 
> > > The gist of this is that test_runner cannot depend on 
> > > content/ [1]. 
> > > 
> > > (Instead, the idea is to add stuff to a WebTestDelegate  
> > > and implement that accordingly).
> > > 
> > > 
> > > [1] https://codereview.chromium.org/1371373002/#msg37
> > 
> > I see. So MockWebUserMediaClient does not actually mock the real
> implementation
> > that well.
> > However, it feels wrong to add a public API in content/public/media_stream
> that
> > should never be called by anyone but the layout tests. It should never be
> called
> > since content::MediaStream  is created from  MediaStreamCenter if the
> > mediastream is created from JS.  If the stream has been created in
> > user_media_client, user_media_client creates content::MediaStream.
> > 
> >
>
https://codereview.chromium.org/1543673002/diff/1/content/renderer/media/medi...
> > File content/renderer/media/media_stream.cc (right):
> > 
> >
>
https://codereview.chromium.org/1543673002/diff/1/content/renderer/media/medi...
> > content/renderer/media/media_stream.cc:23: observers_.clear();
> > On 2016/01/08 00:14:12, mcasas wrote:
> > > On 2016/01/07 09:18:00, perkj_chrome wrote:
> > > > Why this change? Is there a case when the observers can outlive the
> > > MediaStream?
> > > Yes, MediaRecorder is destroyed independently from the MediaStream().
> > > 
> > > > It that case, how do they know that they can not call RemoveObserver ? 
> > > 
> > > Because this is the destructor of the class, that is accessed
> > > via l.14
> > > MediaStream* MediaStream::GetMediaStream(...)
> > > once the dtor has been called, noone should try to
> > > de-register as observer, right?
> > 
> > Right - and hence the DCHECK that no observer is still valid. Because that
> could
> > lead to a heap use after free if the observer call RemoveObserver after the
> > dtor.
> > 
> > A content::MediaStream will never be destroyed as long as the blink
> MediaStream
> > exist. And the blink MediaStream exists as long has there is a reference to
> it.
> > 
> > So the DCHECK(observers_.empty()) is correct I would say.
> > 
> > > 
> > > Correct me if I'm wrong, but this DCHECK was there to
> > > debug some strange race condition appeared on garbage
> > > collection between the only current observer, WebRtc,
> > > and this MediaStream. But honestly, it does not make
> > > sense that MediaStream waits for the Observers to
> > > deregister before going down, specially taken into 
> > > account the complete lack of guarantee from Blink on
> > > the destruction order.
> > > 
> > > Note that I brought this up in the CL description.
> 
> I think we're agreeing to disagree, so I'll try to do this
> observing purely inside Blink by making MediaRecorder
> listen to WebMediaStream::on{add,remove}track instead
> of doing it inside Cr. Thanks for your time reviewer(s)
> and please hold up on this!

And FTR the alternative Blink-only implementation is in
https://codereview.chromium.org/1570263002/. Closing this
CL, cheers!

Powered by Google App Engine
This is Rietveld 408576698