2013-05-17 04:13:01 -07: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-09 14:30:01 -08:00
|
|
|
#include "OpusTrackEncoder.h"
|
2013-05-17 04:13:01 -07: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 11:17:02 -07:00
|
|
|
~OggWriter();
|
2013-05-17 04:13:01 -07:00
|
|
|
|
2013-10-24 19:59:52 -07:00
|
|
|
nsresult WriteEncodedTrack(const EncodedFrameContainer &aData,
|
2015-03-21 09:28:04 -07:00
|
|
|
uint32_t aFlags = 0) override;
|
2013-05-17 04:13:01 -07:00
|
|
|
|
|
|
|
nsresult GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
|
2015-03-21 09:28:04 -07:00
|
|
|
uint32_t aFlags = 0) override;
|
2013-05-17 04:13:01 -07:00
|
|
|
|
2013-10-24 19:59:52 -07:00
|
|
|
// Check metadata type integrity and reject unacceptable track encoder.
|
2015-03-21 09:28:04 -07:00
|
|
|
nsresult SetMetadata(TrackMetadataBase* aMetadata) override;
|
2013-05-17 04:13:01 -07:00
|
|
|
private:
|
|
|
|
nsresult Init();
|
|
|
|
|
2013-10-24 19:59:52 -07:00
|
|
|
nsresult WriteEncodedData(const nsTArray<uint8_t>& aBuffer, int aDuration,
|
|
|
|
uint32_t aFlags = 0);
|
|
|
|
|
|
|
|
void ProduceOggPage(nsTArray<nsTArray<uint8_t> >* aOutputBufs);
|
2013-11-09 14:30:01 -08:00
|
|
|
// Store the Medatata from track encoder
|
2015-10-17 22:24:48 -07:00
|
|
|
RefPtr<OpusMetadata> mMetadata;
|
2013-10-24 19:59:52 -07:00
|
|
|
|
2013-05-17 04:13:01 -07:00
|
|
|
ogg_stream_state mOggStreamState;
|
|
|
|
ogg_page mOggPage;
|
|
|
|
ogg_packet mPacket;
|
|
|
|
};
|
2015-07-13 08:25:42 -07:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-05-17 04:13:01 -07:00
|
|
|
#endif
|