-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Refer to the original PR: #3232 Registers `MediaSource` objects to the `MediaSourceRegistry` through a `MediaSourceAttachment` proxy. The new `MediaSourceAttachment` class is cross-thread reference counting safe, unlike `MediaSource`, which will allow for utilizing `MediaSource` objects created on Dedicated Workers. This change does not add any additional functionality, and is intended as an incremental update towards enabling the creation of `MediaSource` objects on Dedicated Worker threads. See [Chromium's `MediaSourceAttachment` interface][1], and the commit that [initially introduced it][2]. [1]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/media/media_source_attachment.h [2]: https://chromium-review.googlesource.com/c/chromium/src/+/2300804 b/338425449 Change-Id: I016c010c9ef4a0e576bd67ce584d75dbe75986ec Co-authored-by: Drew Thomas <[email protected]>
- Loading branch information
1 parent
4e2d6c8
commit 6d8b4d5
Showing
10 changed files
with
84 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef COBALT_DOM_MEDIA_SOURCE_ATTACHMENT_H_ | ||
#define COBALT_DOM_MEDIA_SOURCE_ATTACHMENT_H_ | ||
|
||
#include "base/memory/ref_counted.h" | ||
#include "cobalt/dom/media_source.h" | ||
#include "cobalt/script/tracer.h" | ||
#include "cobalt/web/url_registry.h" | ||
|
||
namespace cobalt { | ||
namespace dom { | ||
|
||
// Interface for potential cross-context management of MediaSource objects. | ||
// Used with the MediaSourceRegistry for attaching MediaSources to media | ||
// elements. | ||
class MediaSourceAttachment | ||
: public base::RefCountedThreadSafe<MediaSourceAttachment>, | ||
public script::Traceable { | ||
public: | ||
typedef web::UrlRegistry<MediaSourceAttachment> Registry; | ||
|
||
explicit MediaSourceAttachment(scoped_refptr<MediaSource> media_source) | ||
: media_source_(media_source) {} | ||
|
||
scoped_refptr<MediaSource> media_source() const { return media_source_; } | ||
|
||
void TraceMembers(script::Tracer* tracer) override { | ||
tracer->Trace(media_source_); | ||
} | ||
|
||
private: | ||
friend class base::RefCountedThreadSafe<MediaSourceAttachment>; | ||
~MediaSourceAttachment() = default; | ||
|
||
scoped_refptr<MediaSource> media_source_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(MediaSourceAttachment); | ||
}; | ||
|
||
} // namespace dom | ||
} // namespace cobalt | ||
|
||
#endif // COBALT_DOM_MEDIA_SOURCE_ATTACHMENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters