On Thu, Nov 25, 2010 at 6:48 PM, Pid <[email protected]> wrote:
> On 25/11/2010 17:49, declan harrison wrote:
>>> > So far you've shown me that you wrap the output stream, and how the
>>> > write method works.
>>> >
>>> > You haven't actually posted the part of the code where you write your
>>> > bit of the data to the wrapped output stream.
>>> >
>>> >
>>> > p
>> I just call wrapper.write(buf, 0, bug.lenght). Are you looking more
>> source code here?
>
> You are reporting a problem with the response.
>
> You are writing to the output stream, and maybe setting headers on the
> response object.
>
> If you can post each bit of code that interacts with the response object
> we can stop guessing what's wrong and start trying to resolve it.
>
>
> p
>
Apologises about not posting enough of the code, see below for the
methods that sets the respos headers etc
In the method writeResponseHdrs (shown below) we end up reject the
request as bit rate too low and end up executing this code
Log.AdaptVideoError("Video bitrate
["+inputBitRate+"] is
not within range", "Will not encode this video.");
throw new InitialisationException("Video bitrate
["+inputBitRate+"] is not within range. Will not encode this video");
This exception is caught higher up the stack in doPost method which we
then set the status with the following
bufInStream = new
AcceleratorInputStream(request.getInputStream(), 20480);
bufInStream.setHeaderRead();
bufOutStream = new
AcceleratorOutputStream(response.getOutputStream(),20480);
try {
converter = createVideoAdapter(request,
response,
bufInStream,bufOutStream,
request.getContentType(), true,
qualityPolicy);
} catch (Exception ex) {
// caught the exception ok, make sure we have
commited the response
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
====== status code set here and sent in do Post
return;
}
So this is the request that I terminate on the client end before the
respone is actually sent by Tomcat, Im not exactly sure were in Tomcat
the code is when I terminate client request. If I terminate at the
correct point then the next request that re-uses that thread is wrong.
/**
* Write the initial response to the client.
*
* Must write headers before ressponse is committed.
* @throws InitialisationException
* @throws IOException
*
*/
private void writeResponseHdrs() throws InitialisationException,
IOException {
//
// Lets iterate thru the hdrs in the response and
if (responseSet == false) {
setResponseHeaders();
// lets set flag to indicate that hdr have been set
responseSet = true;
//inputStream.setHeaderRead();
outputStream.setHeaderWritten();
// set the status code as well
//
//
if (validateVideoBitate(inputBitRate) == false ) {
//Bitrate check failed - return duration to VR to
facilitate JIT
if (writeResponseHdrs == true) {
streamDuration = mIContainer.getDuration();
response.setContentType( mimeType );
if (metaDuration > 0.0d) {
response.addHeader("x-duration",
String.valueOf(metaDuration));
Log.AdaptVideo("Adding video duration
header on
BR failure [x-duration: "+
String.valueOf(metaDuration)+"]
extracted from onMetaDataTag.");
} else {
// in microseconds
response.addHeader("x-duration",
String.valueOf(streamDuration/1000000));
Log.AdaptVideo("Adding video duration
header on
BR failure [x-duration: "+
String.valueOf(streamDuration/1000000)+"] extracted from container
API.");
}
outputStream.setHeaderWritten();
}
Log.AdaptVideoError("Video bitrate
["+inputBitRate+"] is
not within range", "Will not encode this video.");
throw new InitialisationException("Video bitrate
["+inputBitRate+"] is not within range. Will not encode this video");
}
}
}
private void setResponseHeaders() throws InitialisationException {
Log.AdaptVideoInfo("Adding Http Response headers to help caller");
response.setContentType( mimeType );
// add the following headers for caller
// so that they know what we plan to do
// with the output
// this after initial work
String origLen = request.getHeader("Content-Length");
if (origLen != null) {
response.addHeader("x-orig-content-length", origLen);
Log.AdaptVideo("sending the original length hdr
x-orig-content-length: "+origLen);
} else {
Log.AdaptVideo("Content-Length hdr not present in the request");
}
// add session to manage state for caller e.g. RBA etc
response.addHeader(SESSION_ID, videoSession.key());
Log.AdaptVideo("have added hdr - "+ SESSION_ID +":
"+videoSession.key());
if (metaDuration > 0.0d) {
response.addHeader("x-duration", String.valueOf(metaDuration));
Log.AdaptVideo("video duration header [x-duration: "+
String.valueOf(metaDuration)+"] extracted from
onMetaDataTag.");
} else {
// in microseconds
response.addHeader("x-duration",
String.valueOf(streamDuration/1000000));
Log.AdaptVideo("video duration header [x-duration: "+
String.valueOf(streamDuration/1000000)+"]
extracted from container API.");
}
response.addHeader("x-in-video-codec",getCodecString(mInVideoCodecId));
response.addHeader("x-in-video-fps", String.valueOf(inFrameRate));
response.addHeader("x-in-video-bitrate",
String.valueOf(mInVideoBitRate));
response.addHeader("x-in-audio-codec", getCodecString(mInAudioCodecId));
response.addHeader("x-in-audio-bitrate", String.valueOf(mInAudioBRate));
response.addHeader("x-in-audio-asr", String.valueOf(mInSampleRate));
response.addHeader("x--in-audio-channels",
String.valueOf(mInNumChannels));
}
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]