root/misc/red5/encoder-pipe-r3603.diff
| Revision c88c1e106f88bb7392eaa36fe11844a2b1940d4f, 2.4 kB (checked in by Robin Gareus <robin@…>, 3 years ago) | |
|---|---|
|
|
-
src/org/red5/io/flv/impl/FLVWriter.java
21 21 22 22 import java.io.File; 23 23 import java.io.FileOutputStream; 24 import java.io.OutputStream; 25 import java.nio.ByteBuffer; 26 import java.lang.Process; 24 27 import java.io.IOException; 25 28 import java.io.RandomAccessFile; 26 29 import java.nio.channels.FileChannel; … … 115 118 * need direct access to file to append full duration metadata 116 119 */ 117 120 private File file; 121 122 /** 123 * custom encoder pipe 124 */ 125 private Process encoder; 118 126 119 127 /** 120 128 * Creates writer implementation with given file output stream and last tag … … 154 162 channel = this.fos.getChannel(); 155 163 out = IoBuffer.allocate(1024); 156 164 out.setAutoExpand(true); 165 try { 166 // TODO make this configurable 167 // and pass file-name and some meta-info along 168 this.encoder = Runtime.getRuntime().exec(new String[] {"/home/rgareus/data/coding/inoutC2/misc/red5/myenc"}); 169 } catch (IOException e) { 170 log.error("IO error on FLVpipe", e); 171 } 157 172 } 158 173 159 174 /** … … 185 200 out.putInt(0); 186 201 187 202 out.flip(); 188 203 204 this.encpipe(out.buf()); 189 205 channel.write(out.buf()); 190 206 } 191 207 208 /** 209 * write bytebuffer to encoder pipeline 210 */ 211 private void encpipe(ByteBuffer bb) { 212 ByteBuffer bc = bb.duplicate(); 213 byte[] dst= new byte[bc.remaining()]; 214 bc.get(dst,0,dst.length); 215 try { 216 this.encoder.getOutputStream().write(dst); 217 } catch (IOException e) { ; } 218 } 219 192 220 /** {@inheritDoc} 193 221 */ 194 222 public IStreamableFile getFile() { … … 260 288 out.putInt(0x00); 261 289 262 290 out.flip(); 291 292 this.encpipe(out.buf()); 263 293 bytesWritten += channel.write(out.buf()); 264 294 265 295 IoBuffer bodyBuf = tag.getBody(); 296 297 this.encpipe(bodyBuf.buf()); 266 298 bytesWritten += channel.write(bodyBuf.buf()); 267 299 268 300 if (audioCodecId == -1 && tag.getDataType() == ITag.TYPE_AUDIO) { … … 280 312 out.clear(); 281 313 out.putInt(tag.getBodySize() + 11); 282 314 out.flip(); 315 316 this.encpipe(out.buf()); 283 317 bytesWritten += channel.write(out.buf()); 318 log.debug("written: {}", bytesWritten); 284 319 285 320 return false; 286 321 } … … 296 331 public void close() { 297 332 RandomAccessFile appender = null; 298 333 try { 334 this.encoder.getOutputStream().close(); 299 335 if (metaPosition > 0) { 300 336 long oldPos = channel.position(); 301 337 try {
Note: See TracBrowser
for help on using the browser.
