mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb: Implement some of SourceBuffer.appendBuffer()
Currently, it just fires the error event immediately.
This commit is contained in:
committed by
Gregory Bertilson
parent
e3b37694f5
commit
e627376368
Notes:
github-actions[bot]
2026-04-01 07:56:14 +00:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e627376368c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8655 Reviewed-by: https://github.com/tcl3
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2026-present, the Ladybird developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Function.h>
|
||||
|
||||
namespace Web::MediaSourceExtensions {
|
||||
|
||||
// https://w3c.github.io/media-source/#sourcebuffer-append-state
|
||||
enum class AppendState : u8 {
|
||||
WaitingForSegment,
|
||||
ParsingInitSegment,
|
||||
ParsingMediaSegment,
|
||||
};
|
||||
|
||||
enum class AppendMode : u8 {
|
||||
Segments,
|
||||
Sequence,
|
||||
};
|
||||
|
||||
class SourceBufferProcessor : public AtomicRefCounted<SourceBufferProcessor> {
|
||||
public:
|
||||
SourceBufferProcessor();
|
||||
~SourceBufferProcessor();
|
||||
|
||||
bool updating() const { return m_updating; }
|
||||
void set_updating(bool value) { m_updating = value; }
|
||||
|
||||
AppendMode mode() const;
|
||||
bool is_buffer_full() const;
|
||||
using AppendErrorCallback = Function<void()>;
|
||||
|
||||
void set_append_error_callback(AppendErrorCallback);
|
||||
|
||||
void append_to_input_buffer(ReadonlyBytes);
|
||||
|
||||
void run_segment_parser_loop();
|
||||
void reset_parser_state();
|
||||
void run_coded_frame_eviction();
|
||||
|
||||
private:
|
||||
bool m_updating { false };
|
||||
ByteBuffer m_input_buffer;
|
||||
|
||||
AppendErrorCallback m_append_error_callback;
|
||||
AppendState m_append_state { AppendState::WaitingForSegment };
|
||||
AppendMode m_mode { AppendMode::Segments };
|
||||
bool m_buffer_full_flag { false };
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user