summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/webcodecs/audio_data_attachment.h
blob: c24219a2317e6acd50343c67729f20a40479d203 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBCODECS_AUDIO_DATA_ATTACHMENT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBCODECS_AUDIO_DATA_ATTACHMENT_H_

#include "media/base/audio_buffer.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
#include "third_party/blink/renderer/modules/modules_export.h"

namespace blink {

// Used to serialize AudioData.
class MODULES_EXPORT AudioDataAttachment
    : public SerializedScriptValue::Attachment {
 public:
  using AudioBufferVector = Vector<scoped_refptr<media::AudioBuffer>>;

  static const void* const kAttachmentKey;
  AudioDataAttachment() = default;
  ~AudioDataAttachment() override = default;

  bool IsLockedToAgentCluster() const override {
    return !audio_buffers_.IsEmpty();
  }

  size_t size() const { return audio_buffers_.size(); }

  AudioBufferVector& AudioBuffers() { return audio_buffers_; }

  const AudioBufferVector& AudioBuffers() const { return audio_buffers_; }

 private:
  AudioBufferVector audio_buffers_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBCODECS_AUDIO_DATA_ATTACHMENT_H_