зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1295106 - Part 2: add dequeueInput() and releaseOutput() to codec interface. r=snorp
MozReview-Commit-ID: 90ga1skGfT2 --HG-- extra : rebase_source : e8a06ad446d7bb7bc423032b03c37293a9a98894
This commit is contained in:
Родитель
ce8e57f426
Коммит
ea7f78cbde
|
@ -19,5 +19,8 @@ interface ICodec {
|
|||
oneway void flush();
|
||||
oneway void release();
|
||||
|
||||
Sample dequeueInput(int size);
|
||||
oneway void queueInput(in Sample sample);
|
||||
|
||||
oneway void releaseOutput(in Sample sample);
|
||||
}
|
||||
|
|
|
@ -274,6 +274,11 @@ import java.util.Queue;
|
|||
if (DEBUG) Log.d(LOGTAG, "flushed " + this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Sample dequeueInput(int size) {
|
||||
return Sample.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void queueInput(Sample sample) throws RemoteException {
|
||||
if (!mInputProcessor.onSample(sample)) {
|
||||
|
@ -281,6 +286,10 @@ import java.util.Queue;
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void releaseOutput(Sample sample) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void release() throws RemoteException {
|
||||
if (DEBUG) Log.d(LOGTAG, "release " + this);
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class CodecProxy {
|
|||
protected native void disposeNative();
|
||||
}
|
||||
|
||||
private static class CallbacksForwarder extends ICodecCallbacks.Stub {
|
||||
private class CallbacksForwarder extends ICodecCallbacks.Stub {
|
||||
private final Callbacks mCallbacks;
|
||||
|
||||
CallbacksForwarder(Callbacks callbacks) {
|
||||
|
@ -66,6 +66,7 @@ public final class CodecProxy {
|
|||
@Override
|
||||
public void onOutput(Sample sample) throws RemoteException {
|
||||
mCallbacks.onOutput(sample);
|
||||
mRemote.releaseOutput(sample);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,15 +126,18 @@ public final class CodecProxy {
|
|||
Log.e(LOGTAG, "cannot send input to an ended codec");
|
||||
return false;
|
||||
}
|
||||
Sample sample = (info.flags == MediaCodec.BUFFER_FLAG_END_OF_STREAM) ?
|
||||
Sample.EOS : Sample.create(bytes, info, cryptoInfo);
|
||||
|
||||
try {
|
||||
Sample sample = (info.flags == MediaCodec.BUFFER_FLAG_END_OF_STREAM) ?
|
||||
Sample.EOS : mRemote.dequeueInput(info.size).set(bytes, info, cryptoInfo);
|
||||
mRemote.queueInput(sample);
|
||||
} catch (DeadObjectException e) {
|
||||
return false;
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOGTAG, "fail to input sample:" + sample);
|
||||
Log.e(LOGTAG, "fail to input sample: size=" + info.size +
|
||||
", pts=" + info.presentationTimeUs +
|
||||
", flags=" + Integer.toHexString(info.flags));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -77,6 +77,8 @@ public final class Sample implements Parcelable {
|
|||
public BufferInfo info;
|
||||
public CryptoInfo cryptoInfo;
|
||||
|
||||
public static Sample create() { return create(null, new BufferInfo(), null); }
|
||||
|
||||
public static Sample create(ByteBuffer src, BufferInfo info, CryptoInfo cryptoInfo) {
|
||||
ArrayBuffer buffer = new ArrayBuffer(byteArrayFromBuffer(src, info.offset, info.size));
|
||||
|
||||
|
@ -130,6 +132,16 @@ public final class Sample implements Parcelable {
|
|||
mode);
|
||||
}
|
||||
|
||||
public Sample set(ByteBuffer bytes, BufferInfo info, CryptoInfo cryptoInfo) {
|
||||
if (bytes != null && info.size > 0) {
|
||||
buffer.readFromByteBuffer(bytes, info.offset, info.size);
|
||||
}
|
||||
this.info.set(0, info.size, info.presentationTimeUs, info.flags);
|
||||
this.cryptoInfo = cryptoInfo;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isEOS() {
|
||||
return (this == EOS) ||
|
||||
((info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче