MediaSource, SourceBuffer, SourceBufferList over GStreamer's MSE library; URL.createObjectURL(MediaSource); HTMLMediaElement attaches via mse://. tests/smoke/mse.txt plays chunk-appended fMP4 and WebM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.4 KiB
Rust
42 lines
1.4 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use std::cell::Cell;
|
|
|
|
use js::context::JSContext;
|
|
use js::jsapi::JS::{HeapState, RuntimeHeapState};
|
|
|
|
thread_local!(
|
|
static THREAD_ACTIVE: Cell<bool> = const { Cell::new(true) };
|
|
);
|
|
|
|
pub fn runtime_is_alive() -> bool {
|
|
THREAD_ACTIVE.with(|t| t.get())
|
|
}
|
|
|
|
/// Whether a GC collection is in progress.
|
|
/// Mainly useful for (debug) assertions.
|
|
pub fn during_gc_collection() -> bool {
|
|
// SAFETY: `RuntimeHeapState` only reads thread-local runtime state and has no preconditions.
|
|
matches!(
|
|
unsafe { RuntimeHeapState() },
|
|
HeapState::MajorCollecting | HeapState::MinorCollecting
|
|
)
|
|
}
|
|
|
|
pub fn mark_runtime_dead() {
|
|
THREAD_ACTIVE.with(|t| t.set(false));
|
|
}
|
|
|
|
/// Get the current JSContext for the running thread.
|
|
///
|
|
/// ## Safety
|
|
/// Using this function is unsafe because no other JSContext may be constructed apart from initial ones,
|
|
/// but because we are still working on passing down &mut SafeJSContext references,
|
|
/// this function is provided as temporary workaround/placeholder.
|
|
///
|
|
/// As such all it's usages will need to be eventually replaced with proper &mut SafeJSContext references.
|
|
pub unsafe fn temp_cx() -> JSContext {
|
|
unsafe { JSContext::from_ptr(js::rust::Runtime::get().unwrap()) }
|
|
}
|