From 3fa60052e6fc02030b85b34fed199285bd658451 Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Sun, 13 Sep 2009 15:51:48 +0000 Subject: [PATCH] Adds work on the new MediaService (Work in Progress) --- .../service/media/MediaService.java | 4 +- .../service/neomedia/MediaService.java | 28 ++++++----- .../service/neomedia/device/MediaDevice.java | 46 ++++++++++++++++++- 3 files changed, 63 insertions(+), 15 deletions(-) diff --git a/src/net/java/sip/communicator/service/media/MediaService.java b/src/net/java/sip/communicator/service/media/MediaService.java index af5209d38..f1eba4896 100644 --- a/src/net/java/sip/communicator/service/media/MediaService.java +++ b/src/net/java/sip/communicator/service/media/MediaService.java @@ -55,7 +55,7 @@ public interface MediaService * new random port). */ public static final int BIND_RETRIES_DEFAULT_VALUE = 50; - + /** * With this property video support can be disabled * (enabled by default). @@ -111,7 +111,7 @@ public CallSession createCallSession(Call call) * @param remotePort remote port of for this flow * @param mediaEncodings encoding used for media on this flow * @return a RtpFlow with the corresponding parameters - * @throws MediaException throw a media exception if we fail to create the + * @throws MediaException throw a media exception if we fail to create the * flow */ public RtpFlow createRtpFlow(String localIP, diff --git a/src/net/java/sip/communicator/service/neomedia/MediaService.java b/src/net/java/sip/communicator/service/neomedia/MediaService.java index 7f1ba49c8..701a6eb99 100644 --- a/src/net/java/sip/communicator/service/neomedia/MediaService.java +++ b/src/net/java/sip/communicator/service/neomedia/MediaService.java @@ -6,28 +6,19 @@ */ package net.java.sip.communicator.service.neomedia; +import java.util.*; + import net.java.sip.communicator.service.neomedia.device.*; /** * The MediaService service is meant to be a wrapper of media libraries - * such as JMF, FMJ, FFMPEG, and others. It takes care of all media play and + * such as JMF, FMJ, FFMPEG, and/or others. It takes care of all media play and * capture as well as media transport (e.g. over RTP). * * @author Emil Ivov */ public interface MediaService { - /** - * Returns an array of MediaType instances indicating the types - * that an implementation supports. A MediaType is considered - * supported if an implementation supports either rendering or capturing - * that type of media. - * - * @return an array of MediaType instances indicating the types of - * media that this service supports. - */ - public MediaType[] getSupportedMediaTypes(); - /** * Returns the default MediaDevice for the specified media * type. In most cases users @@ -39,4 +30,17 @@ public interface MediaService * MediaType, or null if no such device exists. */ public MediaDevice getDefaultDevice(MediaType type); + + /** + * Returns a list containing all devices known to this service + * implementation and handling the specified MediaType. + * + * @param mediaType the media type that + * + * @return the list of MediaDevices currently known to handle the + * specified mediaType. + */ + public List getDevices(MediaType mediaType); + + } diff --git a/src/net/java/sip/communicator/service/neomedia/device/MediaDevice.java b/src/net/java/sip/communicator/service/neomedia/device/MediaDevice.java index 751aabed8..12ddf7278 100644 --- a/src/net/java/sip/communicator/service/neomedia/device/MediaDevice.java +++ b/src/net/java/sip/communicator/service/neomedia/device/MediaDevice.java @@ -6,6 +6,11 @@ */ package net.java.sip.communicator.service.neomedia.device; +import java.util.*; + +import net.java.sip.communicator.service.neomedia.*; +import net.java.sip.communicator.service.neomedia.format.*; + /** * The MediaDevice class represents capture and playback devices that * can be used to grab or render media. Sound cards, USB phones and webcams are @@ -13,7 +18,46 @@ * * @author Emil Ivov */ -public class MediaDevice +public interface MediaDevice { + /** + * Direction values + */ + public static enum Direction{ IN, OUT, INOUT}; + /** + * Returns a list of MediaFormat instances representing the media + * formats supported by this MediaDevice. + * + * @return the list of MediaFormats supported by this device. + */ + public List getSupportedFormats(); + + /** + * Returns the MediaType that this device supports. + * + * @return MediaType.AUDIO if this is an audio device or + * MediaType.VIDEO in case of a video device. + */ + public MediaType getMediaType(); + + /** + * Specifies the MediaFormat that this device should use when + * capturing data. + * + * @param format the MediaFormat that this device should use when + * capturing media. + * + * @throws IllegalArgumentException if format is not among + * MediaFormets supported by this MediaDevice. + */ + public void setFormat(MediaFormat format) throws IllegalArgumentException; + /** + * Returns the MediaFormat that this device is currently set to use + * when capturing data. + * + * @return the MediaFormat that this device is currently set to + * provide media in. + */ + public MediaFormat getFormat(); }