public void saveAs ( String name , boolean isAppend ) throws IOException { //log.debug("SaveAs - name: {} append: {}", name, isAppend); // get connection to check if client is still streaming IStreamCapableConnection conn = getConnection ( ) ; if ( conn == null ) { throw new IOException ( "Stream is no longer connected" ) ; } // one recording listener at a time via this entry point if ( recordingListener == null ) { // XXX Paul: Revisit this section to allow for implementation of custom IRecordingListener //IRecordingListener listener = (IRecordingListener) ScopeUtils.getScopeService(conn.getScope(), IRecordingListener.class, RecordingListener.class, false); // create a recording listener IRecordingListener listener = new RecordingListener ( ) ; //log.debug("Created: {}", listener); // initialize the listener if ( listener . init ( conn , name , isAppend ) ) { // get decoder info if it exists for the stream IStreamCodecInfo codecInfo = getCodecInfo ( ) ; //log.debug("Codec info: {}", codecInfo); if ( codecInfo instanceof StreamCodecInfo ) { StreamCodecInfo info = ( StreamCodecInfo ) codecInfo ; IVideoStreamCodec videoCodec = info . getVideoCodec ( ) ; //log.debug("Video codec: {}", videoCodec); if ( videoCodec != null ) { //check for decoder configuration to send IoBuffer config = videoCodec . getDecoderConfiguration ( ) ; if ( config != null ) { //log.debug("Decoder configuration is available for {}", videoCodec.getName()); VideoData videoConf = new VideoData ( config . asReadOnlyBuffer ( ) ) ; try { //log.debug("Setting decoder configuration for recording"); listener . getFileConsumer ( ) . setVideoDecoderConfiguration ( videoConf ) ; } finally { videoConf . release ( ) ; } } } else { log . debug ( "Could not initialize stream output, videoCodec is null." ) ; } IAudioStreamCodec audioCodec = info . getAudioCodec ( ) ; //log.debug("Audio codec: {}", audioCodec); if ( audioCodec != null ) { //check for decoder configuration to send IoBuffer config = audioCodec . getDecoderConfiguration ( ) ; if ( config != null ) { //log.debug("Decoder configuration is available for {}", audioCodec.getName()); AudioData audioConf = new AudioData ( config . asReadOnlyBuffer ( ) ) ; try { //log.debug("Setting decoder configuration for recording"); listener . getFileConsumer ( ) . setAudioDecoderConfiguration ( audioConf ) ; } finally { audioConf . release ( ) ; } } } else { log . debug ( "No decoder configuration available, audioCodec is null." ) ; } } // set as primary listener recordingListener = new WeakReference < IRecordingListener > ( listener ) ; // add as a listener addStreamListener ( listener ) ; // start the listener thread listener . start ( ) ; } else { log . warn ( "Recording listener failed to initialize for stream: {}" , name ) ; } } else { log . debug ( "Recording listener already exists for stream: {} auto record enabled: {}" , name , automaticRecording ) ; } }
Save broadcasted stream .