diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webm/WebMWriter.h | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/media/webm/WebMWriter.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/media/webm/WebMWriter.h b/dom/media/webm/WebMWriter.h new file mode 100644 index 0000000000..71d2e18311 --- /dev/null +++ b/dom/media/webm/WebMWriter.h @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef WebMWriter_h_ +#define WebMWriter_h_ + +#include "ContainerWriter.h" + +namespace mozilla { + +class EbmlComposer; + +// Vorbis meta data structure +class VorbisMetadata : public TrackMetadataBase { + public: + nsTArray<uint8_t> mData; + int32_t mChannels; + float mSamplingFrequency; + MetadataKind GetKind() const override { return METADATA_VORBIS; } +}; + +// VP8 meta data structure +class VP8Metadata : public TrackMetadataBase { + public: + int32_t mWidth; + int32_t mHeight; + int32_t mDisplayWidth; + int32_t mDisplayHeight; + MetadataKind GetKind() const override { return METADATA_VP8; } +}; + +/** + * WebM writer helper + * This class accepts encoder to set audio or video meta data or + * encoded data to ebml Composer, and get muxing data through GetContainerData. + * The ctor/dtor run in the MediaRecorder thread, others run in MediaEncoder + * thread. + */ +class WebMWriter : public ContainerWriter { + public: + // Run in MediaRecorder thread + WebMWriter(); + virtual ~WebMWriter(); + + // WriteEncodedTrack inserts raw packets into WebM stream. Does not accept + // any flags: any specified will be ignored. Writing is finalized via + // flushing via GetContainerData(). + nsresult WriteEncodedTrack(const nsTArray<RefPtr<EncodedFrame>>& aData, + uint32_t aFlags = 0) override; + + // GetContainerData outputs multiplexing data. + // aFlags indicates the muxer should enter into finished stage and flush out + // queue data. + nsresult GetContainerData(nsTArray<nsTArray<uint8_t>>* aOutputBufs, + uint32_t aFlags = 0) override; + + // Assign metadata into muxer + nsresult SetMetadata( + const nsTArray<RefPtr<TrackMetadataBase>>& aMetadata) override; + + private: + UniquePtr<EbmlComposer> mEbmlComposer; +}; + +} // namespace mozilla + +#endif |