content/media/BufferDecoder.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "BufferDecoder.h"
michael@0 8
michael@0 9 #include "nsISupports.h"
michael@0 10 #include "MediaResource.h"
michael@0 11
michael@0 12 namespace mozilla {
michael@0 13
michael@0 14 #ifdef PR_LOGGING
michael@0 15 extern PRLogModuleInfo* gMediaDecoderLog;
michael@0 16 #endif
michael@0 17
michael@0 18 NS_IMPL_ISUPPORTS0(BufferDecoder)
michael@0 19
michael@0 20 BufferDecoder::BufferDecoder(MediaResource* aResource)
michael@0 21 : mReentrantMonitor("BufferDecoder")
michael@0 22 , mResource(aResource)
michael@0 23 {
michael@0 24 MOZ_ASSERT(NS_IsMainThread());
michael@0 25 MOZ_COUNT_CTOR(BufferDecoder);
michael@0 26 #ifdef PR_LOGGING
michael@0 27 if (!gMediaDecoderLog) {
michael@0 28 gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
michael@0 29 }
michael@0 30 #endif
michael@0 31 }
michael@0 32
michael@0 33 BufferDecoder::~BufferDecoder()
michael@0 34 {
michael@0 35 // The dtor may run on any thread, we cannot be sure.
michael@0 36 MOZ_COUNT_DTOR(BufferDecoder);
michael@0 37 }
michael@0 38
michael@0 39 void
michael@0 40 BufferDecoder::BeginDecoding(nsIThread* aDecodeThread)
michael@0 41 {
michael@0 42 MOZ_ASSERT(!mDecodeThread && aDecodeThread);
michael@0 43 mDecodeThread = aDecodeThread;
michael@0 44 }
michael@0 45
michael@0 46 ReentrantMonitor&
michael@0 47 BufferDecoder::GetReentrantMonitor()
michael@0 48 {
michael@0 49 return mReentrantMonitor;
michael@0 50 }
michael@0 51
michael@0 52 bool
michael@0 53 BufferDecoder::IsShutdown() const
michael@0 54 {
michael@0 55 // BufferDecoder cannot be shut down.
michael@0 56 return false;
michael@0 57 }
michael@0 58
michael@0 59 bool
michael@0 60 BufferDecoder::OnStateMachineThread() const
michael@0 61 {
michael@0 62 // BufferDecoder doesn't have the concept of a state machine.
michael@0 63 return true;
michael@0 64 }
michael@0 65
michael@0 66 bool
michael@0 67 BufferDecoder::OnDecodeThread() const
michael@0 68 {
michael@0 69 MOZ_ASSERT(mDecodeThread, "Forgot to call BeginDecoding?");
michael@0 70 return IsCurrentThread(mDecodeThread);
michael@0 71 }
michael@0 72
michael@0 73 MediaResource*
michael@0 74 BufferDecoder::GetResource() const
michael@0 75 {
michael@0 76 return mResource;
michael@0 77 }
michael@0 78
michael@0 79 void
michael@0 80 BufferDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset)
michael@0 81 {
michael@0 82 // ignore
michael@0 83 }
michael@0 84
michael@0 85 void
michael@0 86 BufferDecoder::NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded)
michael@0 87 {
michael@0 88 // ignore
michael@0 89 }
michael@0 90
michael@0 91 int64_t
michael@0 92 BufferDecoder::GetEndMediaTime() const
michael@0 93 {
michael@0 94 // unknown
michael@0 95 return -1;
michael@0 96 }
michael@0 97
michael@0 98 int64_t
michael@0 99 BufferDecoder::GetMediaDuration()
michael@0 100 {
michael@0 101 // unknown
michael@0 102 return -1;
michael@0 103 }
michael@0 104
michael@0 105 void
michael@0 106 BufferDecoder::SetMediaDuration(int64_t aDuration)
michael@0 107 {
michael@0 108 // ignore
michael@0 109 }
michael@0 110
michael@0 111 void
michael@0 112 BufferDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
michael@0 113 {
michael@0 114 // ignore
michael@0 115 }
michael@0 116
michael@0 117 void
michael@0 118 BufferDecoder::SetMediaSeekable(bool aMediaSeekable)
michael@0 119 {
michael@0 120 // ignore
michael@0 121 }
michael@0 122
michael@0 123 void
michael@0 124 BufferDecoder::SetTransportSeekable(bool aTransportSeekable)
michael@0 125 {
michael@0 126 // ignore
michael@0 127 }
michael@0 128
michael@0 129 VideoFrameContainer*
michael@0 130 BufferDecoder::GetVideoFrameContainer()
michael@0 131 {
michael@0 132 // no video frame
michael@0 133 return nullptr;
michael@0 134 }
michael@0 135
michael@0 136 layers::ImageContainer*
michael@0 137 BufferDecoder::GetImageContainer()
michael@0 138 {
michael@0 139 // no image container
michael@0 140 return nullptr;
michael@0 141 }
michael@0 142
michael@0 143 bool
michael@0 144 BufferDecoder::IsTransportSeekable()
michael@0 145 {
michael@0 146 return false;
michael@0 147 }
michael@0 148
michael@0 149 bool
michael@0 150 BufferDecoder::IsMediaSeekable()
michael@0 151 {
michael@0 152 return false;
michael@0 153 }
michael@0 154
michael@0 155 void
michael@0 156 BufferDecoder::MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags)
michael@0 157 {
michael@0 158 // ignore
michael@0 159 }
michael@0 160
michael@0 161 void
michael@0 162 BufferDecoder::QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags)
michael@0 163 {
michael@0 164 // ignore
michael@0 165 }
michael@0 166
michael@0 167 void
michael@0 168 BufferDecoder::SetMediaEndTime(int64_t aTime)
michael@0 169 {
michael@0 170 // ignore
michael@0 171 }
michael@0 172
michael@0 173 void
michael@0 174 BufferDecoder::UpdatePlaybackPosition(int64_t aTime)
michael@0 175 {
michael@0 176 // ignore
michael@0 177 }
michael@0 178
michael@0 179 void
michael@0 180 BufferDecoder::OnReadMetadataCompleted()
michael@0 181 {
michael@0 182 // ignore
michael@0 183 }
michael@0 184
michael@0 185 void
michael@0 186 BufferDecoder::NotifyWaitingForResourcesStatusChanged()
michael@0 187 {
michael@0 188 // ignore
michael@0 189 }
michael@0 190
michael@0 191 MediaDecoderOwner*
michael@0 192 BufferDecoder::GetOwner()
michael@0 193 {
michael@0 194 // unknown
michael@0 195 return nullptr;
michael@0 196 }
michael@0 197
michael@0 198 } // namespace mozilla

mercurial