/* * Copyright (c) 2020, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web::HTML { class HTMLMediaElement : public HTMLElement { WEB_PLATFORM_OBJECT(HTMLMediaElement, HTMLElement); public: virtual ~HTMLMediaElement() override; void queue_a_media_element_task(JS::SafeFunction steps); enum class NetworkState : u16 { Empty, Idle, Loading, NoSource, }; NetworkState network_state() const { return m_network_state; } Bindings::CanPlayTypeResult can_play_type(DeprecatedString const& type) const; void load() const; void pause() const; JS::NonnullGCPtr video_tracks() const { return *m_video_tracks; } protected: HTMLMediaElement(DOM::Document&, DOM::QualifiedName); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: struct EntireResource { }; using ByteRange = Variant; // FIXME: This will need to include "until end" and an actual byte range. virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; Task::Source media_element_event_task_source() const { return m_media_element_event_task_source.source; } WebIDL::ExceptionOr load_element(); WebIDL::ExceptionOr select_resource(); WebIDL::ExceptionOr fetch_resource(AK::URL const&, Function failure_callback); static bool verify_response(JS::NonnullGCPtr, ByteRange const&); WebIDL::ExceptionOr process_media_data(Function failure_callback); WebIDL::ExceptionOr handle_media_source_failure(); void forget_media_resource_specific_tracks(); // https://html.spec.whatwg.org/multipage/media.html#media-element-event-task-source UniqueTaskSource m_media_element_event_task_source {}; // https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate NetworkState m_network_state { NetworkState::Empty }; // https://html.spec.whatwg.org/multipage/media.html#dom-media-videotracks JS::GCPtr m_video_tracks; // https://html.spec.whatwg.org/multipage/media.html#media-data ByteBuffer m_media_data; JS::GCPtr m_fetch_controller; }; }