This definitely looks better!
Here are my first round of comments.
https://codereview.chromium.org/2389473002/diff/1/media/base/mediaplayer_observer.hFile media/base/mediaplayer_observer.h (right):
https://codereview.chromium.org/2389473002/diff/1/media/base/mediaplayer_observer.h#newcode5media/base/mediaplayer_observer.h:5: #ifndef
MEDIA_BASE_MEDIAPLAYER_OBSERVER_H_
nit: media and player are two words.
https://codereview.chromium.org/2389473002/diff/1/media/base/mediaplayer_observer.h#newcode16media/base/mediaplayer_observer.h:16: class MEDIA_EXPORT
MediaPlayerObserver {
As commented before, we don't use "MediaPlayer" outside of media/blink.
Also, the concept of fullscreen doesn't belong to media/base layer as
well. For the former, how about just MediaObserver? We have a
MediaObserver in content/public/browser, but that shouldn't matter. For
the latter, I don't have any better idea at this moment :)
https://codereview.chromium.org/2389473002/diff/1/media/base/mediaplayer_observer.h#newcode21media/base/mediaplayer_observer.h:21: // Called when the media element
or its ancestor is entered/exited fullscreen.
What if the ancestor (e.g. a <div>) entered fullscreen, but the media
element doesn't take 100% width/height of the <div>?
https://codereview.chromium.org/2389473002/diff/1/media/base/mediaplayer_observer.h#newcode25media/base/mediaplayer_observer.h:25: // Called when CDM is attached to
the media element.
Add a comment that the |cdm_context| is only guaranteed to be valid in
this call.
https://codereview.chromium.org/2389473002/diff/1/media/base/mediaplayer_observer.h#newcode28media/base/mediaplayer_observer.h:28: // Set video/audio config after
demuxer is initialized.
nit: "Set" is ambiguous. This is really just notify the observer. How
about "called when audio/video config is available after demuxer is
initialized"?
https://codereview.chromium.org/2389473002/diff/1/media/base/pipeline_metadata.hFile media/base/pipeline_metadata.h (right):
https://codereview.chromium.org/2389473002/diff/1/media/base/pipeline_metadata.h#newcode23media/base/pipeline_metadata.h:23: PipelineMetadata& operator=(const
PipelineMetadata&);
hmm, do you need these?
https://codereview.chromium.org/2389473002/diff/1/media/blink/webmediaplayer_impl.ccFile media/blink/webmediaplayer_impl.cc (right):
https://codereview.chromium.org/2389473002/diff/1/media/blink/webmediaplayer_impl.cc#newcode171media/blink/webmediaplayer_impl.cc:171: const WebMediaPlayerParams&
params)
Since the |observer| is optional, can you put it in
WebMediaPlayerParams? I am not a fan of WebMediaPlayerParams, but for
optional params it seems a good fit.
https://codereview.chromium.org/2389473002/diff/1/media/blink/webmediaplayer_impl.cc#newcode1104media/blink/webmediaplayer_impl.cc:1104:
pipeline_metadata_.video_decoder_config);
So if there's no video, then we don't call OnDecoderConfigChanged() even
if we do have a AudioDecoderConfig... this is not consistent with the
Media*Observer API. Maybe we should always call
OnDecoderConfigChanged(), but the callee will decide what to do?
https://codereview.chromium.org/2389473002/diff/1/media/blink/webmediaplayer_impl.hFile media/blink/webmediaplayer_impl.h (right):
https://codereview.chromium.org/2389473002/diff/1/media/blink/webmediaplayer_impl.h#newcode92media/blink/webmediaplayer_impl.h:92: // |observer| outlives this class,
and could be null.
In your case, the |observer| is the same object as the
|renderer_factory|, which is owned by |this| class. So you can't claim
that the |observer| outlives this class, because in theory, this class
can destroy the |renderer_factory| at any time since |this| owns it.
Is it possible to pass in a weak_ptr of the |observer| so that we don't
need to worry about the life time here?
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.ccFile media/remoting/remoting_controller.cc (right):
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.cc#newcode114media/remoting/remoting_controller.cc:114: return false;
You should be able to DCHECK in OnDecoderConfigChanged() that both
audio/video configs are valid.
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.cc#newcode118media/remoting/remoting_controller.cc:118: case VideoCodec::kCodecVP8:
Just OCC, VP9 is not supported?
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.cc#newcode131media/remoting/remoting_controller.cc:131: return false;
ditto
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.hFile media/remoting/remoting_controller.h (right):
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.h#newcode22media/remoting/remoting_controller.h:22: class MEDIA_EXPORT
RemotingController final : public MediaPlayerObserver,
You should NOT use MEDIA_EXPORT since this class doesn't belong to the
"media" target.
Actually since media/remoting is a source_set, I think you don't need
*_EXPORT. Could you please check whether you really need this? If you
do, media_remoting should have it's own EXPORT, e.g.
MEDIA_REMOTING_EXPORT, similar to MEDIA_BLINK_EXPORT.
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.h#newcode26media/remoting/remoting_controller.h:26: // remain valid after the
constructor returns.
It's a bit odd that you pass in a factory and use it immediately in the
ctor. In that case, why don't you call remoter_factory->Create() first,
then construct this class, and pass in the RemotingSourceRequest and
RemoterPtr? IMHO that feels more natural and you don't need this comment
any more.
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.h#newcode36media/remoting/remoting_controller.h:36: void
OnStopped(mojom::RemotingStopReason reson) override;
s/reson/reason
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.h#newcode43media/remoting/remoting_controller.h:43: const VideoDecoderConfig&
video_config) override;
nit: empty line here
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.h#newcode55media/remoting/remoting_controller.h:55: bool isAudioConfigSupported();
nit: s/is/Is
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.h#newcode59media/remoting/remoting_controller.h:59: void Update();
nit: this function name seems too generic and doesn't reflect what it
does...
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.h#newcode62media/remoting/remoting_controller.h:62: bool is_fullscreen_;
nit: you can specify default value here, but different folder has
different rule, so it's totally up to you.
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_controller.h#newcode80media/remoting/remoting_controller.h:80: const
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
Looks like this class single threaded? If so, add a comment.
Also, it seems you only use |task_runner_| to make sure everything runs
on the same thread. In this case, you can use ThreadChecker:
https://cs.chromium.org/chromium/src/base/threading/thread_checker.h?q=ThreadChecker&sq=package:chromium&dr=CSshttps://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_renderer_factory.ccFile media/remoting/remoting_renderer_factory.cc (right):
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_renderer_factory.cc#newcode29media/remoting/remoting_renderer_factory.cc:29: return
std::unique_ptr<Renderer>();
If you check in this code today will this cause trouble? We assume
CreateRenderer() never returns a nullptr:
https://cs.chromium.org/chromium/src/media/filters/pipeline_controller.cc?rcl=1475263265&l=53https://cs.chromium.org/chromium/src/media/base/pipeline_impl.cc?rcl=1475263265&l=897https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_renderer_factory.hFile media/remoting/remoting_renderer_factory.h (right):
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_renderer_factory.h#newcode14media/remoting/remoting_renderer_factory.h:14: }
You don't need this since they are from RendererFactory
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_renderer_factory.h#newcode19media/remoting/remoting_renderer_factory.h:19: class VideoRendererSink;
ditto
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_renderer_factory.h#newcode24media/remoting/remoting_renderer_factory.h:24: class MEDIA_EXPORT
RemotingRendererFactory : public RendererFactory {
ditto about EXPORT
https://codereview.chromium.org/2389473002/diff/1/media/remoting/remoting_renderer_factory.h#newcode40media/remoting/remoting_renderer_factory.h:40:
std::unique_ptr<RemotingController> const remoting_controller_;
style nit: "putting the const first"
https://google.github.io/styleguide/cppguide.html#Use_of_consthttps://codereview.chromium.org/2389473002/diff/1/third_party/WebKit/public/platform/WebMediaPlayer.hFile third_party/WebKit/public/platform/WebMediaPlayer.h (right):
https://codereview.chromium.org/2389473002/diff/1/third_party/WebKit/public/platform/WebMediaPlayer.h#newcode202third_party/WebKit/public/platform/WebMediaPlayer.h:202: virtual void
ancestorExitedFullscreen() {}
See my previous comment on this. What if there are other elements
sharing the same ancestor with the media element?
You need someone who's more familiar with blink/elements/fullscreen to
review this.
https://codereview.chromium.org/2389473002/