SourceBufferList.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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/SourceBufferListPrototype.h>
  8. #include <LibWeb/MediaSourceExtensions/EventNames.h>
  9. #include <LibWeb/MediaSourceExtensions/SourceBufferList.h>
  10. namespace Web::MediaSourceExtensions {
  11. GC_DEFINE_ALLOCATOR(SourceBufferList);
  12. SourceBufferList::SourceBufferList(JS::Realm& realm)
  13. : DOM::EventTarget(realm)
  14. {
  15. }
  16. SourceBufferList::~SourceBufferList() = default;
  17. void SourceBufferList::initialize(JS::Realm& realm)
  18. {
  19. Base::initialize(realm);
  20. WEB_SET_PROTOTYPE_FOR_INTERFACE(SourceBufferList);
  21. }
  22. // https://w3c.github.io/media-source/#dom-sourcebufferlist-onaddsourcebuffer
  23. void SourceBufferList::set_onaddsourcebuffer(GC::Ptr<WebIDL::CallbackType> event_handler)
  24. {
  25. set_event_handler_attribute(EventNames::addsourcebuffer, event_handler);
  26. }
  27. // https://w3c.github.io/media-source/#dom-sourcebufferlist-onaddsourcebuffer
  28. GC::Ptr<WebIDL::CallbackType> SourceBufferList::onaddsourcebuffer()
  29. {
  30. return event_handler_attribute(EventNames::addsourcebuffer);
  31. }
  32. // https://w3c.github.io/media-source/#dom-sourcebufferlist-onremovesourcebuffer
  33. void SourceBufferList::set_onremovesourcebuffer(GC::Ptr<WebIDL::CallbackType> event_handler)
  34. {
  35. set_event_handler_attribute(EventNames::removesourcebuffer, event_handler);
  36. }
  37. // https://w3c.github.io/media-source/#dom-sourcebufferlist-onremovesourcebuffer
  38. GC::Ptr<WebIDL::CallbackType> SourceBufferList::onremovesourcebuffer()
  39. {
  40. return event_handler_attribute(EventNames::removesourcebuffer);
  41. }
  42. }