ladybird/Libraries/LibWeb/HTML/MediaTrackBase.h
Zaggy1024 51c3f7c41e LibWeb: Implement appending and demuxing WebM MSE segments
The segments are parsed for the SourceBufferProcessor by the
WebMByteStreamParser. It parses the initialization segment to update
its internal set of tracks, then SourceBufferProcessor/SourceBuffer set
them up for playback. When a media segment is received, it also parses
as much of it as is available, returning all the coded frames found so
far. SourceBufferProcessor then tells TrackBufferDemuxer to remove any
overlapping frames and insert the new ones.

TrackBufferDemuxer implements the Demuxer interface in terms of the
coded frame store maintained by the SourceBufferProcessor. It returns
the frames in decode order when requested by a data provider. When a
is needed, it finds the keyframe prior to the target timestamp, and
checks that there are no gaps in data up to the target timestamp. If
there are any gaps, it blocks until the gaps are gone.
2026-04-01 02:54:22 -05:00

58 lines
1.9 KiB
C++

/*
* Copyright (c) 2025, Gregory Bertilson <gregory@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibMedia/Track.h>
#include <LibWeb/Bindings/PlatformObject.h>
namespace Web::HTML {
class MediaTrackBase : public Bindings::PlatformObject {
WEB_NON_IDL_PLATFORM_OBJECT(MediaTrackBase, Bindings::PlatformObject);
public:
virtual ~MediaTrackBase() override;
HTMLMediaElement& media_element() const { return *m_media_element; }
Media::Track const& track_in_playback_manager() const { return m_track_in_playback_manager; }
Utf16String const& id() const { return m_id; }
void set_id(Utf16String const& id) { m_id = id; }
Utf16View kind() const { return Media::track_kind_to_string(m_kind); }
void set_kind(Media::Track::Kind kind) { m_kind = kind; }
Utf16String const& label() const { return m_label; }
Utf16String const& language() const { return m_language; }
protected:
MediaTrackBase(JS::Realm&, GC::Ref<HTMLMediaElement>, Media::Track const&);
virtual void visit_edges(Cell::Visitor&) override;
private:
GC::Ref<HTMLMediaElement> m_media_element;
Media::Track m_track_in_playback_manager;
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-id
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-id
Utf16String m_id;
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-kind
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-kind
Media::Track::Kind m_kind;
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-label
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-label
Utf16String m_label;
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-language
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-language
Utf16String m_language;
};
}