ladybird/Libraries/LibWeb/HTML/AudioTrackList.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

61 lines
1.7 KiB
C++

/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Badge.h>
#include <AK/String.h>
#include <LibGC/RootVector.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HTML/AudioTrack.h>
namespace Web::HTML {
class AudioTrackList final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(AudioTrackList, DOM::EventTarget);
GC_DECLARE_ALLOCATOR(AudioTrackList);
public:
void add_track(GC::Ref<AudioTrack>);
void remove_all_tracks();
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotracklist-length
size_t length() const { return m_audio_tracks.size(); }
GC::Ptr<AudioTrack> get_track_by_id(StringView id) const;
bool has_enabled_track() const;
template<typename Callback>
void for_each_track(Callback&& callback)
{
for (auto& audio_track : m_audio_tracks) {
auto iteration_decision = callback(*audio_track);
if (iteration_decision == IterationDecision::Break)
break;
}
}
void set_onchange(WebIDL::CallbackType*);
WebIDL::CallbackType* onchange();
void set_onaddtrack(WebIDL::CallbackType*);
WebIDL::CallbackType* onaddtrack();
void set_onremovetrack(WebIDL::CallbackType*);
WebIDL::CallbackType* onremovetrack();
private:
explicit AudioTrackList(JS::Realm&);
virtual void visit_edges(Visitor&) override;
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const& property_name) const override;
Vector<GC::Ref<AudioTrack>> m_audio_tracks;
};
}