forked from mirrors/gecko-dev
		
	Backed out 2 changesets (bug 1552607) for causing checkstyle failures. CLOSED TREE
Backed out changeset 53a39e402451 (bug 1552607) Backed out changeset 6385b8616d54 (bug 1552607)
This commit is contained in:
		
							parent
							
								
									01bd4dbcc7
								
							
						
					
					
						commit
						74781bb639
					
				
					 6 changed files with 14 additions and 38 deletions
				
			
		|  | @ -437,7 +437,7 @@ class RemoteAudioDecoder : public RemoteDataDecoder { | ||||||
|     return mFirstDemuxedSampleTime->ToMicroseconds() > aTime; |     return mFirstDemuxedSampleTime->ToMicroseconds() > aTime; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   bool ShouldDiscardSample(int64_t aSession) const { |   bool ShouldDiscardSample() const { | ||||||
|     AssertOnTaskQueue(); |     AssertOnTaskQueue(); | ||||||
|     // HandleOutput() runs on Android binder thread pool and could be preempted
 |     // HandleOutput() runs on Android binder thread pool and could be preempted
 | ||||||
|     // by RemoteDateDecoder task queue. That means ProcessOutput() could be
 |     // by RemoteDateDecoder task queue. That means ProcessOutput() could be
 | ||||||
|  | @ -445,8 +445,7 @@ class RemoteAudioDecoder : public RemoteDataDecoder { | ||||||
|     // sample which is returned after calling Shutdown() and Flush(). We can
 |     // sample which is returned after calling Shutdown() and Flush(). We can
 | ||||||
|     // check mFirstDemuxedSampleTime to know whether the Flush() has been
 |     // check mFirstDemuxedSampleTime to know whether the Flush() has been
 | ||||||
|     // called, becasue it would be reset in Flush().
 |     // called, becasue it would be reset in Flush().
 | ||||||
|     return GetState() == State::SHUTDOWN || !mFirstDemuxedSampleTime || |     return GetState() == State::SHUTDOWN || !mFirstDemuxedSampleTime; | ||||||
|            mSession != aSession; |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // Param and LocalRef are only valid for the duration of a JNI method call.
 |   // Param and LocalRef are only valid for the duration of a JNI method call.
 | ||||||
|  | @ -467,7 +466,7 @@ class RemoteAudioDecoder : public RemoteDataDecoder { | ||||||
| 
 | 
 | ||||||
|     AssertOnTaskQueue(); |     AssertOnTaskQueue(); | ||||||
| 
 | 
 | ||||||
|     if (ShouldDiscardSample(aSample->Session()) || !aBuffer->IsValid()) { |     if (ShouldDiscardSample() || !aBuffer->IsValid()) { | ||||||
|       aSample->Dispose(); |       aSample->Dispose(); | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  | @ -591,7 +590,6 @@ RemoteDataDecoder::RemoteDataDecoder(MediaData::Type aType, | ||||||
|       mFormat(aFormat), |       mFormat(aFormat), | ||||||
|       mDrmStubId(aDrmStubId), |       mDrmStubId(aDrmStubId), | ||||||
|       mTaskQueue(aTaskQueue), |       mTaskQueue(aTaskQueue), | ||||||
|       mSession(0), |  | ||||||
|       mNumPendingInputs(0) {} |       mNumPendingInputs(0) {} | ||||||
| 
 | 
 | ||||||
| RefPtr<MediaDataDecoder::FlushPromise> RemoteDataDecoder::Flush() { | RefPtr<MediaDataDecoder::FlushPromise> RemoteDataDecoder::Flush() { | ||||||
|  | @ -608,7 +606,6 @@ RefPtr<MediaDataDecoder::FlushPromise> RemoteDataDecoder::ProcessFlush() { | ||||||
|   mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__); |   mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__); | ||||||
|   mDrainPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__); |   mDrainPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__); | ||||||
|   SetState(State::DRAINED); |   SetState(State::DRAINED); | ||||||
|   mSession++; |  | ||||||
|   mJavaDecoder->Flush(); |   mJavaDecoder->Flush(); | ||||||
|   return FlushPromise::CreateAndResolve(true, __func__); |   return FlushPromise::CreateAndResolve(true, __func__); | ||||||
| } | } | ||||||
|  | @ -636,7 +633,7 @@ RefPtr<MediaDataDecoder::DecodePromise> RemoteDataDecoder::Drain() { | ||||||
|     SetState(State::DRAINING); |     SetState(State::DRAINING); | ||||||
|     self->mInputBufferInfo->Set(0, 0, -1, |     self->mInputBufferInfo->Set(0, 0, -1, | ||||||
|                                 MediaCodec::BUFFER_FLAG_END_OF_STREAM); |                                 MediaCodec::BUFFER_FLAG_END_OF_STREAM); | ||||||
|     mJavaDecoder->Input(nullptr, self->mInputBufferInfo, nullptr, mSession); |     mJavaDecoder->Input(nullptr, self->mInputBufferInfo, nullptr); | ||||||
|     return p; |     return p; | ||||||
|   }); |   }); | ||||||
| } | } | ||||||
|  | @ -743,7 +740,7 @@ RefPtr<MediaDataDecoder::DecodePromise> RemoteDataDecoder::ProcessDecode( | ||||||
|   SetState(State::DRAINABLE); |   SetState(State::DRAINABLE); | ||||||
|   mInputBufferInfo->Set(0, aSample->Size(), aSample->mTime.ToMicroseconds(), 0); |   mInputBufferInfo->Set(0, aSample->Size(), aSample->mTime.ToMicroseconds(), 0); | ||||||
|   return mJavaDecoder->Input(bytes, mInputBufferInfo, |   return mJavaDecoder->Input(bytes, mInputBufferInfo, | ||||||
|                              GetCryptoInfoFromSample(aSample), mSession) |                              GetCryptoInfoFromSample(aSample)) | ||||||
|              ? mDecodePromise.Ensure(__func__) |              ? mDecodePromise.Ensure(__func__) | ||||||
|              : DecodePromise::CreateAndReject( |              : DecodePromise::CreateAndReject( | ||||||
|                    MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__); |                    MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__); | ||||||
|  | @ -831,7 +828,6 @@ void RemoteDataDecoder::DrainComplete() { | ||||||
|   } |   } | ||||||
|   SetState(State::DRAINED); |   SetState(State::DRAINED); | ||||||
|   ReturnDecodedData(); |   ReturnDecodedData(); | ||||||
|   mSession++; |  | ||||||
|   // Make decoder accept input again.
 |   // Make decoder accept input again.
 | ||||||
|   mJavaDecoder->Flush(); |   mJavaDecoder->Flush(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -82,10 +82,6 @@ class RemoteDataDecoder : public MediaDataDecoder, | ||||||
|   // information. Contents must be changed only on mTaskQueue.
 |   // information. Contents must be changed only on mTaskQueue.
 | ||||||
|   java::sdk::BufferInfo::GlobalRef mInputBufferInfo; |   java::sdk::BufferInfo::GlobalRef mInputBufferInfo; | ||||||
| 
 | 
 | ||||||
|   // Session ID attached to samples. It's increased every time
 |  | ||||||
|   // CodecProxy::Flush() is called. Accessed on mTaskqueue only.
 |  | ||||||
|   int64_t mSession; |  | ||||||
| 
 |  | ||||||
|  private: |  private: | ||||||
|   enum class PendingOp { INCREASE, DECREASE, CLEAR }; |   enum class PendingOp { INCREASE, DECREASE, CLEAR }; | ||||||
|   void UpdatePendingInputStatus(PendingOp aOp); |   void UpdatePendingInputStatus(PendingOp aOp); | ||||||
|  |  | ||||||
|  | @ -1113,7 +1113,7 @@ int32_t WebrtcMediaCodecVP8VideoRemoteEncoder::Encode( | ||||||
|     bufferInfo->Set(0, size, inputImage.render_time_ms() * PR_USEC_PER_MSEC, 0); |     bufferInfo->Set(0, size, inputImage.render_time_ms() * PR_USEC_PER_MSEC, 0); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   mJavaEncoder->Input(bytes, bufferInfo, nullptr, 0); |   mJavaEncoder->Input(bytes, bufferInfo, nullptr); | ||||||
| 
 | 
 | ||||||
|   return WEBRTC_VIDEO_CODEC_OK; |   return WEBRTC_VIDEO_CODEC_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -69,7 +69,6 @@ import org.mozilla.gecko.gfx.GeckoSurface; | ||||||
|         private Queue<Sample> mDequeuedSamples = new LinkedList<>(); |         private Queue<Sample> mDequeuedSamples = new LinkedList<>(); | ||||||
|         private Queue<Input> mInputSamples = new LinkedList<>(); |         private Queue<Input> mInputSamples = new LinkedList<>(); | ||||||
|         private boolean mStopped; |         private boolean mStopped; | ||||||
|         private long mSession; |  | ||||||
| 
 | 
 | ||||||
|         private synchronized Sample onAllocate(final int size) { |         private synchronized Sample onAllocate(final int size) { | ||||||
|             Sample sample = mSamplePool.obtainInput(size); |             Sample sample = mSamplePool.obtainInput(size); | ||||||
|  | @ -90,12 +89,10 @@ import org.mozilla.gecko.gfx.GeckoSurface; | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (sample.session >= mSession) { |             Sample dequeued = mDequeuedSamples.remove(); | ||||||
|                 Sample dequeued = mDequeuedSamples.remove(); |             dequeued.setBufferInfo(sample.info); | ||||||
|                 dequeued.setBufferInfo(sample.info); |             dequeued.setCryptoInfo(sample.cryptoInfo); | ||||||
|                 dequeued.setCryptoInfo(sample.cryptoInfo); |             queueSample(dequeued); | ||||||
|                 queueSample(dequeued); |  | ||||||
|             } |  | ||||||
| 
 | 
 | ||||||
|             sample.dispose(); |             sample.dispose(); | ||||||
|         } |         } | ||||||
|  | @ -148,9 +145,6 @@ import org.mozilla.gecko.gfx.GeckoSurface; | ||||||
|         private void feedSampleToBuffer() { |         private void feedSampleToBuffer() { | ||||||
|             while (!mAvailableInputBuffers.isEmpty() && !mInputSamples.isEmpty()) { |             while (!mAvailableInputBuffers.isEmpty() && !mInputSamples.isEmpty()) { | ||||||
|                 int index = mAvailableInputBuffers.poll(); |                 int index = mAvailableInputBuffers.poll(); | ||||||
|                 if (!isValidBuffer(index)) { |  | ||||||
|                     continue; |  | ||||||
|                 } |  | ||||||
|                 int len = 0; |                 int len = 0; | ||||||
|                 final Sample sample = mInputSamples.poll().sample; |                 final Sample sample = mInputSamples.poll().sample; | ||||||
|                 long pts = sample.info.presentationTimeUs; |                 long pts = sample.info.presentationTimeUs; | ||||||
|  | @ -213,7 +207,6 @@ import org.mozilla.gecko.gfx.GeckoSurface; | ||||||
|             mDequeuedSamples.clear(); |             mDequeuedSamples.clear(); | ||||||
| 
 | 
 | ||||||
|             mAvailableInputBuffers.clear(); |             mAvailableInputBuffers.clear(); | ||||||
|             mSession++; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private synchronized void start() { |         private synchronized void start() { | ||||||
|  | @ -247,7 +240,6 @@ import org.mozilla.gecko.gfx.GeckoSurface; | ||||||
|         private boolean mHasOutputCapacitySet; |         private boolean mHasOutputCapacitySet; | ||||||
|         private Queue<Output> mSentOutputs = new LinkedList<>(); |         private Queue<Output> mSentOutputs = new LinkedList<>(); | ||||||
|         private boolean mStopped; |         private boolean mStopped; | ||||||
|         private long mSession; |  | ||||||
| 
 | 
 | ||||||
|         private OutputProcessor(final boolean renderToSurface) { |         private OutputProcessor(final boolean renderToSurface) { | ||||||
|             mRenderToSurface = renderToSurface; |             mRenderToSurface = renderToSurface; | ||||||
|  | @ -261,7 +253,6 @@ import org.mozilla.gecko.gfx.GeckoSurface; | ||||||
|             try { |             try { | ||||||
|                 Sample output = obtainOutputSample(index, info); |                 Sample output = obtainOutputSample(index, info); | ||||||
|                 mSentOutputs.add(new Output(output, index)); |                 mSentOutputs.add(new Output(output, index)); | ||||||
|                 output.session = mSession; |  | ||||||
|                 mCallbacks.onOutput(output); |                 mCallbacks.onOutput(output); | ||||||
|             } catch (Exception e) { |             } catch (Exception e) { | ||||||
|                 e.printStackTrace(); |                 e.printStackTrace(); | ||||||
|  | @ -341,7 +332,6 @@ import org.mozilla.gecko.gfx.GeckoSurface; | ||||||
|                 mSamplePool.recycleOutput(o.sample); |                 mSamplePool.recycleOutput(o.sample); | ||||||
|             } |             } | ||||||
|             mSentOutputs.clear(); |             mSentOutputs.clear(); | ||||||
|             mSession++; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private synchronized void start() { |         private synchronized void start() { | ||||||
|  |  | ||||||
|  | @ -224,7 +224,7 @@ public final class CodecProxy { | ||||||
| 
 | 
 | ||||||
|     @WrapForJNI |     @WrapForJNI | ||||||
|     public synchronized boolean input(final ByteBuffer bytes, final BufferInfo info, |     public synchronized boolean input(final ByteBuffer bytes, final BufferInfo info, | ||||||
|                                       final CryptoInfo cryptoInfo, final long session) { |                                       final CryptoInfo cryptoInfo) { | ||||||
|         if (mRemote == null) { |         if (mRemote == null) { | ||||||
|             Log.e(LOGTAG, "cannot send input to an ended codec"); |             Log.e(LOGTAG, "cannot send input to an ended codec"); | ||||||
|             return false; |             return false; | ||||||
|  | @ -239,7 +239,7 @@ public final class CodecProxy { | ||||||
|         try { |         try { | ||||||
|             Sample s = mRemote.dequeueInput(info.size); |             Sample s = mRemote.dequeueInput(info.size); | ||||||
|             fillInputBuffer(s.bufferId, bytes, info.offset, info.size); |             fillInputBuffer(s.bufferId, bytes, info.offset, info.size); | ||||||
|             return sendInput(s.set(info, cryptoInfo, session)); |             return sendInput(s.set(info, cryptoInfo)); | ||||||
|         } catch (RemoteException | NullPointerException e) { |         } catch (RemoteException | NullPointerException e) { | ||||||
|             Log.e(LOGTAG, "fail to dequeue input buffer", e); |             Log.e(LOGTAG, "fail to dequeue input buffer", e); | ||||||
|         } catch (IOException e) { |         } catch (IOException e) { | ||||||
|  |  | ||||||
|  | @ -22,8 +22,6 @@ public final class Sample implements Parcelable { | ||||||
|         EOS = new Sample(); |         EOS = new Sample(); | ||||||
|         EOS.info.set(0, 0, Long.MIN_VALUE, MediaCodec.BUFFER_FLAG_END_OF_STREAM); |         EOS.info.set(0, 0, Long.MIN_VALUE, MediaCodec.BUFFER_FLAG_END_OF_STREAM); | ||||||
|     } |     } | ||||||
|     @WrapForJNI |  | ||||||
|     public long session; |  | ||||||
| 
 | 
 | ||||||
|     public static final int NO_BUFFER = -1; |     public static final int NO_BUFFER = -1; | ||||||
| 
 | 
 | ||||||
|  | @ -73,10 +71,9 @@ public final class Sample implements Parcelable { | ||||||
|                       mode); |                       mode); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Sample set(final BufferInfo info, final CryptoInfo cryptoInfo, long session) { |     public Sample set(final BufferInfo info, final CryptoInfo cryptoInfo) { | ||||||
|         setBufferInfo(info); |         setBufferInfo(info); | ||||||
|         setCryptoInfo(cryptoInfo); |         setCryptoInfo(cryptoInfo); | ||||||
|         this.session = session; |  | ||||||
|         return this; |         return this; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -147,7 +144,6 @@ public final class Sample implements Parcelable { | ||||||
|             } else { |             } else { | ||||||
|                 s = new Sample(); |                 s = new Sample(); | ||||||
|             } |             } | ||||||
|             s.session = in.readLong(); |  | ||||||
|             s.bufferId = in.readInt(); |             s.bufferId = in.readInt(); | ||||||
|             s.readInfo(in); |             s.readInfo(in); | ||||||
|             s.readCrypto(in); |             s.readCrypto(in); | ||||||
|  | @ -162,7 +158,6 @@ public final class Sample implements Parcelable { | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void writeToParcel(final Parcel dest, final int parcelableFlags) { |     public void writeToParcel(final Parcel dest, final int parcelableFlags) { | ||||||
|         dest.writeLong(session); |  | ||||||
|         dest.writeInt(bufferId); |         dest.writeInt(bufferId); | ||||||
|         writeInfo(dest); |         writeInfo(dest); | ||||||
|         writeCrypto(dest); |         writeCrypto(dest); | ||||||
|  | @ -211,8 +206,7 @@ public final class Sample implements Parcelable { | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         StringBuilder str = new StringBuilder(); |         StringBuilder str = new StringBuilder(); | ||||||
|         str.append("{ session#:").append(session). |         str.append("{ buffer#").append(bufferId). | ||||||
|                 append(", buffer#").append(bufferId). |  | ||||||
|                 append(", info="). |                 append(", info="). | ||||||
|                 append("{ offset=").append(info.offset). |                 append("{ offset=").append(info.offset). | ||||||
|                 append(", size=").append(info.size). |                 append(", size=").append(info.size). | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Mihai Alexandru Michis
						Mihai Alexandru Michis