public MediaStreamSource(InputStream mediaStream, String mediaType, DateTime lastModified, long contentLength) { super(mediaType); this.mediaStream = mediaStream; this.lastModified = lastModified; this.contentLength = contentLength; if (mediaStream instanceof SharedInputStream) { sharedMediaStreamStart = ((SharedInputStream)mediaStream).getPosition(); } }
public InputStream getInputStream() { // If the underlying stream implements SharedInputStream, then get // a new stream so the stream source can be read multiple times. InputStream returnStream = (mediaStream instanceof SharedInputStream) ? ((SharedInputStream)mediaStream).newStream(sharedMediaStreamStart, -1) : mediaStream; return returnStream; }