ManagedMediaSource.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/Bindings/ManagedMediaSourcePrototype.h>
  8. #include <LibWeb/MediaSourceExtensions/EventNames.h>
  9. #include <LibWeb/MediaSourceExtensions/ManagedMediaSource.h>
  10. namespace Web::MediaSourceExtensions {
  11. GC_DEFINE_ALLOCATOR(ManagedMediaSource);
  12. WebIDL::ExceptionOr<GC::Ref<ManagedMediaSource>> ManagedMediaSource::construct_impl(JS::Realm& realm)
  13. {
  14. return realm.create<ManagedMediaSource>(realm);
  15. }
  16. ManagedMediaSource::ManagedMediaSource(JS::Realm& realm)
  17. : MediaSource(realm)
  18. {
  19. }
  20. ManagedMediaSource::~ManagedMediaSource() = default;
  21. void ManagedMediaSource::initialize(JS::Realm& realm)
  22. {
  23. Base::initialize(realm);
  24. WEB_SET_PROTOTYPE_FOR_INTERFACE(ManagedMediaSource);
  25. }
  26. // https://w3c.github.io/media-source/#dom-managedmediasource-onstartstreaming
  27. void ManagedMediaSource::set_onstartstreaming(GC::Ptr<WebIDL::CallbackType> event_handler)
  28. {
  29. set_event_handler_attribute(EventNames::startstreaming, event_handler);
  30. }
  31. // https://w3c.github.io/media-source/#dom-managedmediasource-onstartstreaming
  32. GC::Ptr<WebIDL::CallbackType> ManagedMediaSource::onstartstreaming()
  33. {
  34. return event_handler_attribute(EventNames::startstreaming);
  35. }
  36. // https://w3c.github.io/media-source/#dom-managedmediasource-onendstreaming
  37. void ManagedMediaSource::set_onendstreaming(GC::Ptr<WebIDL::CallbackType> event_handler)
  38. {
  39. set_event_handler_attribute(EventNames::endstreaming, event_handler);
  40. }
  41. // https://w3c.github.io/media-source/#dom-managedmediasource-onendstreaming
  42. GC::Ptr<WebIDL::CallbackType> ManagedMediaSource::onendstreaming()
  43. {
  44. return event_handler_attribute(EventNames::endstreaming);
  45. }
  46. }