2013-05-17 15:13:01 +04:00
|
|
|
/* -*- 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 OggWriter_h_
|
|
|
|
#define OggWriter_h_
|
|
|
|
|
|
|
|
#include "ContainerWriter.h"
|
2013-11-10 02:30:01 +04:00
|
|
|
#include "OpusTrackEncoder.h"
|
2013-05-17 15:13:01 +04:00
|
|
|
#include <ogg/ogg.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
/**
|
|
|
|
* WriteEncodedTrack inserts raw packets into Ogg stream (ogg_stream_state), and
|
|
|
|
* GetContainerData outputs an ogg_page when enough packets have been written
|
|
|
|
* to the Ogg stream.
|
|
|
|
* For more details, please reference:
|
|
|
|
* http://www.xiph.org/ogg/doc/libogg/encoding.html
|
|
|
|
*/
|
|
|
|
class OggWriter : public ContainerWriter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OggWriter();
|
2014-03-11 22:17:02 +04:00
|
|
|
~OggWriter();
|
2013-05-17 15:13:01 +04:00
|
|
|
|
2013-10-25 06:59:52 +04:00
|
|
|
nsresult WriteEncodedTrack(const EncodedFrameContainer &aData,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aFlags = 0) override;
|
2013-05-17 15:13:01 +04:00
|
|
|
|
|
|
|
nsresult GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aFlags = 0) override;
|
2013-05-17 15:13:01 +04:00
|
|
|
|
2013-10-25 06:59:52 +04:00
|
|
|
// Check metadata type integrity and reject unacceptable track encoder.
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult SetMetadata(TrackMetadataBase* aMetadata) override;
|
2013-05-17 15:13:01 +04:00
|
|
|
private:
|
|
|
|
nsresult Init();
|
|
|
|
|
2013-10-25 06:59:52 +04:00
|
|
|
nsresult WriteEncodedData(const nsTArray<uint8_t>& aBuffer, int aDuration,
|
|
|
|
uint32_t aFlags = 0);
|
|
|
|
|
|
|
|
void ProduceOggPage(nsTArray<nsTArray<uint8_t> >* aOutputBufs);
|
2013-11-10 02:30:01 +04:00
|
|
|
// Store the Medatata from track encoder
|
|
|
|
nsRefPtr<OpusMetadata> mMetadata;
|
2013-10-25 06:59:52 +04:00
|
|
|
|
2013-05-17 15:13:01 +04:00
|
|
|
ogg_stream_state mOggStreamState;
|
|
|
|
ogg_page mOggPage;
|
|
|
|
ogg_packet mPacket;
|
|
|
|
};
|
2015-07-13 18:25:42 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-05-17 15:13:01 +04:00
|
|
|
#endif
|