Skip to content

Commit

Permalink
Rename MediaSource attachment methods (#3179)
Browse files Browse the repository at this point in the history
The methods used to attach a MediaSource to an element do not currently
align with those used by Chromium. This change renames the methods to
have similar names to those used upstream.

* [Recent Chromium
methods](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/mediasource/media_source.h;l=118-131;drc=9ed4a90ee6aeaa3c1911d229dec6317d8fe8260d;bpv=0;bpt=0)
* [Relevant Chromium
commit](https://chromium-review.googlesource.com/c/chromium/src/+/2079384)

b/338426134

Change-Id: I0621a93c757d6df4dcb3ad64811707f7c933a13f
  • Loading branch information
at-ninja committed May 7, 2024
1 parent 73d21d1 commit 43f89aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cobalt/dom/html_media_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ void HTMLMediaElement::LoadResource(const GURL& initial_url,
NoneSupported("Media source is NULL.");
return;
}
if (!media_source_->AttachToElement(this)) {
if (!media_source_->StartAttachingToMediaElement(this)) {
media_source_ = nullptr;
NoneSupported("Unable to attach media source.");
return;
Expand Down Expand Up @@ -1643,7 +1643,7 @@ void HTMLMediaElement::SourceOpened(ChunkDemuxer* chunk_demuxer) {
DCHECK(chunk_demuxer);
BeginProcessingMediaPlayerCallback();
DCHECK(media_source_);
media_source_->SetChunkDemuxerAndOpen(chunk_demuxer);
media_source_->CompleteAttachingToMediaElement(chunk_demuxer);
EndProcessingMediaPlayerCallback();
}

Expand Down
5 changes: 3 additions & 2 deletions cobalt/dom/media_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ bool MediaSource::IsTypeSupported(script::EnvironmentSettings* settings,
}
}

bool MediaSource::AttachToElement(HTMLMediaElement* media_element) {
bool MediaSource::StartAttachingToMediaElement(
HTMLMediaElement* media_element) {
if (attached_element_) {
return false;
}
Expand Down Expand Up @@ -431,7 +432,7 @@ bool MediaSource::AttachToElement(HTMLMediaElement* media_element) {
return true;
}

void MediaSource::SetChunkDemuxerAndOpen(ChunkDemuxer* chunk_demuxer) {
void MediaSource::CompleteAttachingToMediaElement(ChunkDemuxer* chunk_demuxer) {
DCHECK(chunk_demuxer);
DCHECK(!chunk_demuxer_);
DCHECK(attached_element_);
Expand Down
4 changes: 2 additions & 2 deletions cobalt/dom/media_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class MediaSource : public web::EventTarget {
// Custom, not in any spec.
//
// HTMLMediaSource
bool AttachToElement(HTMLMediaElement* media_element);
void SetChunkDemuxerAndOpen(ChunkDemuxer* chunk_demuxer);
bool StartAttachingToMediaElement(HTMLMediaElement* media_element);
void CompleteAttachingToMediaElement(ChunkDemuxer* chunk_demuxer);
void Close();
bool IsClosed() const;
scoped_refptr<TimeRanges> GetBufferedRange() const;
Expand Down

0 comments on commit 43f89aa

Please sign in to comment.