feat: context bridge support VideoFrame (#47316)
* feat: context bridge support VideoFrame * docs: add VideoFrame to docs
This commit is contained in:
parent
a0d983e4b5
commit
095e622a6a
2 changed files with 14 additions and 0 deletions
|
@ -157,6 +157,7 @@ has been included below for completeness:
|
||||||
| [Cloneable Types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) | Simple | ✅ | ✅ | See the linked document on cloneable types |
|
| [Cloneable Types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) | Simple | ✅ | ✅ | See the linked document on cloneable types |
|
||||||
| `Element` | Complex | ✅ | ✅ | Prototype modifications are dropped. Sending custom elements will not work. |
|
| `Element` | Complex | ✅ | ✅ | Prototype modifications are dropped. Sending custom elements will not work. |
|
||||||
| `Blob` | Complex | ✅ | ✅ | N/A |
|
| `Blob` | Complex | ✅ | ✅ | N/A |
|
||||||
|
| `VideoFrame` | Complex | ✅ | ✅ | N/A |
|
||||||
| `Symbol` | N/A | ❌ | ❌ | Symbols cannot be copied across contexts so they are dropped |
|
| `Symbol` | N/A | ❌ | ❌ | Symbols cannot be copied across contexts so they are dropped |
|
||||||
|
|
||||||
If the type you care about is not in the above table, it is probably not supported.
|
If the type you care about is not in the above table, it is probably not supported.
|
||||||
|
|
|
@ -28,7 +28,9 @@
|
||||||
#include "third_party/blink/public/web/web_blob.h"
|
#include "third_party/blink/public/web/web_blob.h"
|
||||||
#include "third_party/blink/public/web/web_element.h"
|
#include "third_party/blink/public/web/web_element.h"
|
||||||
#include "third_party/blink/public/web/web_local_frame.h"
|
#include "third_party/blink/public/web/web_local_frame.h"
|
||||||
|
#include "third_party/blink/renderer/bindings/modules/v8/v8_video_frame.h" // nogncheck
|
||||||
#include "third_party/blink/renderer/core/execution_context/execution_context.h" // nogncheck
|
#include "third_party/blink/renderer/core/execution_context/execution_context.h" // nogncheck
|
||||||
|
#include "third_party/blink/renderer/modules/webcodecs/video_frame.h" // nogncheck
|
||||||
|
|
||||||
namespace features {
|
namespace features {
|
||||||
BASE_FEATURE(kContextBridgeMutability,
|
BASE_FEATURE(kContextBridgeMutability,
|
||||||
|
@ -414,6 +416,17 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContextInner(
|
||||||
v8::Context::Scope destination_context_scope(destination_context);
|
v8::Context::Scope destination_context_scope(destination_context);
|
||||||
return v8::MaybeLocal<v8::Value>(blob.ToV8Value(destination_isolate));
|
return v8::MaybeLocal<v8::Value>(blob.ToV8Value(destination_isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom logic to "clone" VideoFrame references
|
||||||
|
blink::VideoFrame* video_frame =
|
||||||
|
blink::V8VideoFrame::ToWrappable(source_context->GetIsolate(), value);
|
||||||
|
if (video_frame != nullptr) {
|
||||||
|
blink::ScriptState* script_state = blink::ScriptState::ForCurrentRealm(
|
||||||
|
destination_context->GetIsolate());
|
||||||
|
return v8::MaybeLocal<v8::Value>(
|
||||||
|
blink::ToV8Traits<blink::VideoFrame>::ToV8(script_state,
|
||||||
|
video_frame));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proxy all objects
|
// Proxy all objects
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue