예제 #1
0
 /** Stops any currently active recording. */
 public void stopRecording() {
   IRecordingListener listener = null;
   if (recordingListener != null && (listener = recordingListener.get()).isRecording()) {
     notifyRecordingStop();
     // remove the listener
     removeStreamListener(listener);
     // stop the recording listener
     listener.stop();
     // clear and null-out the thread local
     recordingListener.clear();
     recordingListener = null;
   }
 }
예제 #2
0
 /** {@inheritDoc} */
 public void saveAs(String name, boolean isAppend) throws IOException {
   // one recording listener at a time via this entry point
   if (recordingListener == null) {
     IScope scope = getScope();
     // create a recording listener
     IRecordingListener listener =
         (IRecordingListener)
             ScopeUtils.getScopeService(scope, IRecordingListener.class, RecordingListener.class);
     // initialize the listener
     if (listener.init(scope, 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<>(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.info("Recording listener already exists for stream: {}", name);
   }
 }