Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef OggWriter_h_
7 #define OggWriter_h_
9 #include "ContainerWriter.h"
10 #include "OpusTrackEncoder.h"
11 #include <ogg/ogg.h>
13 namespace mozilla {
14 /**
15 * WriteEncodedTrack inserts raw packets into Ogg stream (ogg_stream_state), and
16 * GetContainerData outputs an ogg_page when enough packets have been written
17 * to the Ogg stream.
18 * For more details, please reference:
19 * http://www.xiph.org/ogg/doc/libogg/encoding.html
20 */
21 class OggWriter : public ContainerWriter
22 {
23 public:
24 OggWriter();
25 ~OggWriter();
27 nsresult WriteEncodedTrack(const EncodedFrameContainer &aData,
28 uint32_t aFlags = 0) MOZ_OVERRIDE;
30 nsresult GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
31 uint32_t aFlags = 0) MOZ_OVERRIDE;
33 // Check metadata type integrity and reject unacceptable track encoder.
34 nsresult SetMetadata(TrackMetadataBase* aMetadata) MOZ_OVERRIDE;
35 private:
36 nsresult Init();
38 nsresult WriteEncodedData(const nsTArray<uint8_t>& aBuffer, int aDuration,
39 uint32_t aFlags = 0);
41 void ProduceOggPage(nsTArray<nsTArray<uint8_t> >* aOutputBufs);
42 // Store the Medatata from track encoder
43 nsRefPtr<OpusMetadata> mMetadata;
45 ogg_stream_state mOggStreamState;
46 ogg_page mOggPage;
47 ogg_packet mPacket;
48 };
49 }
50 #endif