diff --git a/src/net/java/sip/communicator/impl/neomedia/MediaServiceImpl.java b/src/net/java/sip/communicator/impl/neomedia/MediaServiceImpl.java index cd1ca3bae..41867b450 100644 --- a/src/net/java/sip/communicator/impl/neomedia/MediaServiceImpl.java +++ b/src/net/java/sip/communicator/impl/neomedia/MediaServiceImpl.java @@ -119,6 +119,11 @@ public class MediaServiceImpl */ private static Map dynamicPayloadTypePreferences; + /** + * The volume control of the media service playback. + */ + private static VolumeControl volumeControl; + /** * Create a MediaStream which will use a specific * MediaDevice for capture and playback of media. The new instance @@ -530,6 +535,17 @@ public ZrtpControl createZrtpControl() return new ZrtpControlImpl(); } + /** + * Returns the control that handles current playback levels. + * + * @return the volume playback control. + */ + public VolumeControl getVolumeControl() + { + // returns the uninitialized value as still not implemented + return volumeControl; + } + /** * Get available screens. * diff --git a/src/net/java/sip/communicator/service/neomedia/MediaService.java b/src/net/java/sip/communicator/service/neomedia/MediaService.java index baa96b29c..58f52735c 100644 --- a/src/net/java/sip/communicator/service/neomedia/MediaService.java +++ b/src/net/java/sip/communicator/service/neomedia/MediaService.java @@ -138,6 +138,12 @@ public MediaStream createMediaStream(StreamConnector connector, */ public ZrtpControl createZrtpControl(); + /** + * Returns the control that handles current playback levels. + * @return the volume playback control. + */ + public VolumeControl getVolumeControl(); + /** * Get available ScreenDevices. * diff --git a/src/net/java/sip/communicator/service/neomedia/VolumeControl.java b/src/net/java/sip/communicator/service/neomedia/VolumeControl.java new file mode 100644 index 000000000..5dbf25da4 --- /dev/null +++ b/src/net/java/sip/communicator/service/neomedia/VolumeControl.java @@ -0,0 +1,71 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.neomedia; + +import net.java.sip.communicator.service.neomedia.event.*; + +/** + * Controls the playback volume in media service. + * + * @author Damian Minkov + */ +public interface VolumeControl +{ + public final static String PLAYBACK_VOLUME_LEVEL_PROPERTY_NAME + = "net.java.sip.communicator.service.media.PLAYBACK_VOLUME_LEVEL"; + + /** + * Current volume value. + * @return the current volume level. + */ + public float getVolume(); + + /** + * Returns the minimum allowed volume value. + * @return the minimum allowed volume value. + */ + public float getMinValue(); + + /** + * Returns the maximum allowed volume value. + * @return the maximum allowed volume value. + */ + public float getMaxValue(); + + /** + * Changes volume level. + * @param value the new level to set. + * @return the actual level which was set. + */ + public float setVolume(float value); + + /** + * Mutes current sound playback. + * @param mute mutes/unmutes playback. + */ + public void setMute(boolean mute); + + /** + * Get mute state of sound playback. + * @return mute state of sound playback. + */ + public boolean getMute(); + + /** + * Adds a VolumeChangeListener to be informed for any change + * in the volume levels. + * + * @param listener volume change listener. + */ + public void addVolumeChangeListener(VolumeChangeListener listener); + + /** + * Removes a VolumeChangeListener. + * @param listener the volume change listener to be removed. + */ + public void removeVolumeChangeListener(VolumeChangeListener listener); +} diff --git a/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeEvent.java b/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeEvent.java new file mode 100644 index 000000000..169acc1a6 --- /dev/null +++ b/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeEvent.java @@ -0,0 +1,73 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.neomedia.event; + +import net.java.sip.communicator.service.neomedia.*; + +import java.util.*; + +/** + * Represents the event fired when playback volume value has changed. + * + * @author Damian Minkov + */ +public class VolumeChangeEvent + extends EventObject +{ + /** + * Current level of volume. + */ + private float level; + + /** + * Is volume muted. + */ + private boolean mute; + + /** + * Constructs a VolumeChangeEvent with current values. + * + * @param source Volume control from which the change comes. + * @param level volume level. + * @param mute is muted. + * @throws IllegalArgumentException if source is null. + */ + public VolumeChangeEvent(VolumeControl source, float level, boolean mute) + { + super(source); + + this.level = level; + this.mute = mute; + } + + /** + * The source control which has changed the volume. + * @return the volume control. + */ + public VolumeControl getSourceVolumeControl() + { + return (VolumeControl)getSource(); + } + + /** + * Current volume level. + * @return current volume level. + */ + public float getLevel() + { + return level; + } + + /** + * Is current volume muted. + * @return is current volume muted. + */ + public boolean getMute() + { + return mute; + } +} diff --git a/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeListener.java b/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeListener.java new file mode 100644 index 000000000..82db7ce62 --- /dev/null +++ b/src/net/java/sip/communicator/service/neomedia/event/VolumeChangeListener.java @@ -0,0 +1,22 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.neomedia.event; + +/** + * VolumeChangeListener used to notify for changes in the + * playback volume. + * + * @author Damian Minkov + */ +public interface VolumeChangeListener +{ + /** + * Event fired when volume has changed. + * @param volumeChangeEvent the volume change event. + */ + public void volumeChange(VolumeChangeEvent volumeChangeEvent); +}