diff options
Diffstat (limited to 'src/net/java/sip/communicator/impl/neomedia/device')
-rw-r--r-- | src/net/java/sip/communicator/impl/neomedia/device/AudioMixerMediaDevice.java | 77 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceSession.java | 63 |
2 files changed, 54 insertions, 86 deletions
diff --git a/src/net/java/sip/communicator/impl/neomedia/device/AudioMixerMediaDevice.java b/src/net/java/sip/communicator/impl/neomedia/device/AudioMixerMediaDevice.java index 307bab1..2d92cfa 100644 --- a/src/net/java/sip/communicator/impl/neomedia/device/AudioMixerMediaDevice.java +++ b/src/net/java/sip/communicator/impl/neomedia/device/AudioMixerMediaDevice.java @@ -206,83 +206,6 @@ public class AudioMixerMediaDevice } /** - * Create a new recording session. - * - * @param contentDescriptor the content descriptor for the session. - * @return a new <tt>MediaDeviceSession</tt> - */ - public synchronized MediaDeviceSession createRecordingSession( - final ContentDescriptor contentDescriptor) - { - if (deviceSession == null) - deviceSession = new AudioMixerMediaDeviceSession(); - - return new MediaStreamMediaDeviceSession(deviceSession) - { - /** - * Starts a specific <tt>Processor</tt> if this - * <tt>MediaDeviceSession</tt> has been started and the specified - * <tt>Processor</tt> is not started. Does not check the - * <tt>MediaDirection</tt> of this session when starting. - * - * @param processor the <tt>Processor</tt> to start - */ - @Override - protected void startProcessorInAccordWithDirection( - Processor processor) - { - if (processor.getState() != Processor.Started) - { - processor.start(); - if (logger.isTraceEnabled()) - { - logger.trace( - "Started Processor with hashCode " - + processor.hashCode()); - } - } - } - - /** - * Overrides the method to set the processor's content descriptor - * to <tt>FileTypeDescriptor.MPEG_AUDIO</tt>. - * - * @param event the <tt>ControllerEvent</tt> specifying the - * <tt>Controller</tt> which is the source of the event and the very - * type of the event - */ - @Override - protected void processorControllerUpdate(ControllerEvent event) - { - super.processorControllerUpdate(event); - - if (event instanceof ConfigureCompleteEvent) - { - Processor processor = (Processor) event. - getSourceController(); - - if (processor != null) - { - try - { - processor.setContentDescriptor(contentDescriptor); - } - catch (NotConfiguredError nce) - { - logger.error( - "Failed to set ContentDescriptor to Processor.", - nce); - } - - if (format != null) - setProcessorFormat(processor, format); - } - } - } - }; - } - - /** * Notifies all currently registered <tt>SimpleAudioLevelListener</tt>s * that our local media now has audio level <tt>level</tt>. * diff --git a/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceSession.java b/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceSession.java index 6bdc0d1..06af083 100644 --- a/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceSession.java +++ b/src/net/java/sip/communicator/impl/neomedia/device/MediaDeviceSession.java @@ -71,6 +71,13 @@ public class MediaDeviceSession private boolean captureDeviceIsConnected; /** + * The <tt>ContentDescriptor</tt> which specifies the content type in which + * this <tt>MediaDeviceSession</tt> is to output the media captured by its + * <tt>MediaDevice</tt>. + */ + private ContentDescriptor contentDescriptor; + + /** * The <tt>MediaDevice</tt> used by this instance to capture and play back * media. */ @@ -498,6 +505,27 @@ public class MediaDeviceSession } /** + * Creates a <tt>ContentDescriptor</tt> to be set on a specific + * <tt>Processor</tt> of captured media to be sent to the remote peer. + * Allows extenders to override. The default implementation returns + * {@link ContentDescriptor#RAW_RTP}. + * + * @param processor the <tt>Processor</tt> of captured media to be sent to + * the remote peer which is to have its <tt>contentDescriptor</tt> set to + * the returned <tt>ContentDescriptor</tt> + * @return a <tt>ContentDescriptor</tt> to be set on the specified + * <tt>processor</tt> of captured media to be sent to the remote peer + */ + protected ContentDescriptor createProcessorContentDescriptor( + Processor processor) + { + return + (contentDescriptor == null) + ? new ContentDescriptor(ContentDescriptor.RAW_RTP) + : contentDescriptor; + } + + /** * Makes sure {@link #captureDevice} is disconnected. */ private void disconnectCaptureDevice() @@ -705,13 +733,13 @@ public class MediaDeviceSession continue; Format jmfFormat = trackControl.getFormat(); - MediaType type = jmfFormat instanceof VideoFormat - ? MediaType.VIDEO : MediaType.AUDIO; + MediaType type + = (jmfFormat instanceof VideoFormat) + ? MediaType.VIDEO + : MediaType.AUDIO; - if(mediaType.equals((type))) - { + if(mediaType.equals(type)) return jmfFormat; - } } } return null; @@ -1113,10 +1141,8 @@ public class MediaDeviceSession { try { - processor - .setContentDescriptor( - new ContentDescriptor( - ContentDescriptor.RAW_RTP)); + processor.setContentDescriptor( + createProcessorContentDescriptor(processor)); } catch (NotConfiguredError nce) { @@ -1220,6 +1246,25 @@ public class MediaDeviceSession } /** + * Sets the <tt>ContentDescriptor</tt> which specifies the content type in + * which this <tt>MediaDeviceSession</tt> is to output the media captured by + * its <tt>MediaDevice</tt>. The default content type in which + * <tt>MediaDeviceSession</tt> outputs the media captured by its + * <tt>MediaDevice</tt> is {@link ContentDescriptor#RAW_RTP}. + * + * @param contentDescriptor the <tt>ContentDescriptor</tt> which specifies + * the content type in which this <tt>MediaDeviceSession</tt> is to output + * the media captured by its <tt>MediaDevice</tt> + */ + public void setContentDescriptor(ContentDescriptor contentDescriptor) + { + if (contentDescriptor == null) + throw new NullPointerException("contentDescriptor"); + + this.contentDescriptor = contentDescriptor; + } + + /** * Sets the <tt>MediaFormat</tt> in which this <tt>MediaDeviceSession</tt> * outputs the media captured by its <tt>MediaDevice</tt>. * |