RequestQueuepublic class RequestQueue extends Object A queue of bursts of requests.
This queue maintains the count of frames that have been produced, and is thread safe. |
Fields Summary |
---|
private static final String | TAG | private static final long | INVALID_FRAME | private BurstHolder | mRepeatingRequest | private final ArrayDeque | mRequestQueue | private long | mCurrentFrameNumber | private long | mCurrentRepeatingFrameNumber | private int | mCurrentRequestId | private final List | mJpegSurfaceIds |
Constructors Summary |
---|
public RequestQueue(List jpegSurfaceIds)
mJpegSurfaceIds = jpegSurfaceIds;
|
Methods Summary |
---|
private long | calculateLastFrame(int requestId)
long total = mCurrentFrameNumber;
for (BurstHolder b : mRequestQueue) {
total += b.getNumberOfRequests();
if (b.getRequestId() == requestId) {
return total - 1;
}
}
throw new IllegalStateException(
"At least one request must be in the queue to calculate frame number");
| public synchronized android.util.Pair | getNext()Return and remove the next burst on the queue.
If a repeating burst is returned, it will not be removed.
BurstHolder next = mRequestQueue.poll();
if (next == null && mRepeatingRequest != null) {
next = mRepeatingRequest;
mCurrentRepeatingFrameNumber = mCurrentFrameNumber +
next.getNumberOfRequests();
}
if (next == null) {
return null;
}
Pair<BurstHolder, Long> ret = new Pair<BurstHolder, Long>(next, mCurrentFrameNumber);
mCurrentFrameNumber += next.getNumberOfRequests();
return ret;
| public synchronized long | stopRepeating(int requestId)Cancel a repeating request.
long ret = INVALID_FRAME;
if (mRepeatingRequest != null && mRepeatingRequest.getRequestId() == requestId) {
mRepeatingRequest = null;
ret = (mCurrentRepeatingFrameNumber == INVALID_FRAME) ? INVALID_FRAME :
mCurrentRepeatingFrameNumber - 1;
mCurrentRepeatingFrameNumber = INVALID_FRAME;
Log.i(TAG, "Repeating capture request cancelled.");
} else {
Log.e(TAG, "cancel failed: no repeating request exists for request id: " + requestId);
}
return ret;
| public synchronized long | stopRepeating()Cancel a repeating request.
if (mRepeatingRequest == null) {
Log.e(TAG, "cancel failed: no repeating request exists.");
return INVALID_FRAME;
}
return stopRepeating(mRepeatingRequest.getRequestId());
| public synchronized int | submit(java.util.List requests, boolean repeating, android.hardware.camera2.utils.LongParcelable frameNumber)Add a the given burst to the queue.
If the burst is repeating, replace the current repeating burst.
int requestId = mCurrentRequestId++;
BurstHolder burst = new BurstHolder(requestId, repeating, requests, mJpegSurfaceIds);
long ret = INVALID_FRAME;
if (burst.isRepeating()) {
Log.i(TAG, "Repeating capture request set.");
if (mRepeatingRequest != null) {
ret = (mCurrentRepeatingFrameNumber == INVALID_FRAME) ? INVALID_FRAME :
mCurrentRepeatingFrameNumber - 1;
}
mCurrentRepeatingFrameNumber = INVALID_FRAME;
mRepeatingRequest = burst;
} else {
mRequestQueue.offer(burst);
ret = calculateLastFrame(burst.getRequestId());
}
frameNumber.setNumber(ret);
return requestId;
|
|