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
41
42
43
44
45
46
47
48
49
50
51
52
53
media / fuchsia / common / passthrough_sysmem_buffer_stream.h [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_FUCHSIA_COMMON_PASSTHROUGH_SYSMEM_BUFFER_STREAM_H_
#define MEDIA_FUCHSIA_COMMON_PASSTHROUGH_SYSMEM_BUFFER_STREAM_H_
#include "base/memory/raw_ptr.h"
#include "media/fuchsia/common/sysmem_buffer_stream.h"
#include "media/fuchsia/common/sysmem_client.h"
#include "media/fuchsia/common/vmo_buffer_writer_queue.h"
namespace media {
// A SysmemBufferStream that simply writes the stream to sysmem buffers.
class MEDIA_EXPORT PassthroughSysmemBufferStream : public SysmemBufferStream {
public:
explicit PassthroughSysmemBufferStream(
SysmemAllocatorClient* sysmem_allocator);
~PassthroughSysmemBufferStream() override;
PassthroughSysmemBufferStream(const PassthroughSysmemBufferStream&) = delete;
PassthroughSysmemBufferStream& operator=(
const PassthroughSysmemBufferStream&) = delete;
// SysmemBufferStream implementation:
void Initialize(Sink* sink,
size_t min_buffer_size,
size_t min_buffer_count) override;
void EnqueueBuffer(scoped_refptr<DecoderBuffer> buffer) override;
void Reset() override;
private:
void OnBuffersAcquired(
std::vector<VmoBuffer> buffers,
const fuchsia::sysmem2::SingleBufferSettings& buffer_settings);
// Callbacks for VmoBufferWriterQueue.
void ProcessOutputPacket(const DecoderBuffer* buffer,
StreamProcessorHelper::IoPacket packet);
void ProcessEndOfStream();
raw_ptr<Sink> sink_ = nullptr;
const raw_ptr<SysmemAllocatorClient> sysmem_allocator_;
std::unique_ptr<SysmemCollectionClient> output_buffer_collection_;
VmoBufferWriterQueue queue_;
};
} // namespace media
#endif // MEDIA_FUCHSIA_COMMON_PASSTHROUGH_SYSMEM_BUFFER_STREAM_H_