diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2011-06-17 15:50:03 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2011-06-17 15:50:03 +0000 |
commit | 5744ceede0c7cf4ac9f8992b9643976e148f74b8 (patch) | |
tree | d45d14fbcdc530e4ead825aed0d76ed1c0fb7147 /src/net/java/sip/communicator/service/neomedia | |
parent | 88bab9eb924413f995f4f4a0d55fa45b92929d65 (diff) | |
download | jitsi-5744ceede0c7cf4ac9f8992b9643976e148f74b8.zip jitsi-5744ceede0c7cf4ac9f8992b9643976e148f74b8.tar.gz jitsi-5744ceede0c7cf4ac9f8992b9643976e148f74b8.tar.bz2 |
Responds to INFO requests for key frames.
Diffstat (limited to 'src/net/java/sip/communicator/service/neomedia')
-rw-r--r-- | src/net/java/sip/communicator/service/neomedia/control/KeyFrameControl.java | 66 | ||||
-rw-r--r-- | src/net/java/sip/communicator/service/neomedia/control/KeyFrameControlAdapter.java | 129 |
2 files changed, 195 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControl.java b/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControl.java index 7da13ba..65554e8 100644 --- a/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControl.java +++ b/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControl.java @@ -17,6 +17,22 @@ import java.util.*; public interface KeyFrameControl
{
/**
+ * Adds a <tt>KeyFrameRequestee</tt> to be made available through this
+ * <tt>KeyFrameControl</tt>.
+ *
+ * @param index the zero-based index at which <tt>keyFrameRequestee</tt> is
+ * to be added to the list of <tt>KeyFrameRequestee</tt>s made available or
+ * <tt>-1</tt> to have this <tt>KeyFrameControl</tt> choose at which index
+ * it is to be added in accord with its internal logic
+ * through this <tt>KeyFrameControl</tt>
+ * @param keyFrameRequestee the <tt>KeyFrameRequestee</tt> to be added to
+ * this <tt>KeyFrameControl</tt> so that it is made available through it
+ */
+ public void addKeyFrameRequestee(
+ int index,
+ KeyFrameRequestee keyFrameRequestee);
+
+ /**
* Adds a <tt>KeyFrameRequester</tt> to be made available through this
* <tt>KeyFrameControl</tt>.
*
@@ -33,6 +49,15 @@ public interface KeyFrameControl KeyFrameRequester keyFrameRequester);
/**
+ * Gets the <tt>KeyFrameRequestee</tt>s made available through this
+ * <tt>KeyFrameControl</tt>.
+ *
+ * @return an unmodifiable list of <tt>KeyFrameRequestee</tt>s made
+ * available through this <tt>KeyFrameControl</tt>
+ */
+ public List<KeyFrameRequestee> getKeyFrameRequestees();
+
+ /**
* Gets the <tt>KeyFrameRequester</tt>s made available through this
* <tt>KeyFrameControl</tt>.
*
@@ -42,6 +67,28 @@ public interface KeyFrameControl public List<KeyFrameRequester> getKeyFrameRequesters();
/**
+ * Notifies this <tt>KeyFrameControl</tt> that the remote peer of the
+ * associated <tt>VideoMediaStream</tt> has requested a key frame from the
+ * local peer.
+ *
+ * @return <tt>true</tt> if the local peer has honored the request from the
+ * remote peer for a key frame; otherwise, <tt>false</tt>
+ */
+ public boolean keyFrameRequest();
+
+ /**
+ * Removes a <tt>KeyFrameRequestee</tt> to no longer be made available
+ * through this <tt>KeyFrameControl</tt>.
+ *
+ * @param keyFrameRequestee the <tt>KeyFrameRequestee</tt> to be removed
+ * from this <tt>KeyFrameControl</tt> so that it is no longer made available
+ * through it
+ * @return <tt>true</tt> if <tt>keyFrameRequestee</tt> was found in this
+ * <tt>KeyFrameControl</tt>; otherwise, <tt>false</tt>
+ */
+ public boolean removeKeyFrameRequestee(KeyFrameRequestee keyFrameRequestee);
+
+ /**
* Removes a <tt>KeyFrameRequester</tt> to no longer be made available
* through this <tt>KeyFrameControl</tt>.
*
@@ -54,6 +101,25 @@ public interface KeyFrameControl public boolean removeKeyFrameRequester(KeyFrameRequester keyFrameRequester);
/**
+ * Represents a way for the remote peer of a <tt>VideoMediaStream</tt> to
+ * request a key frame from its local peer.
+ *
+ * @author Lyubomir Marinov
+ */
+ public interface KeyFrameRequestee
+ {
+ /**
+ * Notifies this <tt>KeyFrameRequestee</tt> that the remote peer of the
+ * associated <tt>VideoMediaStream</tt> requests a key frame from the
+ * local peer.
+ *
+ * @return <tt>true</tt> if this <tt>KeyFrameRequestee</tt> has honored
+ * the request for a key frame; otherwise, <tt>false</tt>
+ */
+ public boolean keyFrameRequest();
+ }
+
+ /**
* Represents a way for a <tt>VideoMediaStream</tt> to request a key frame
* from its remote peer.
*
diff --git a/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControlAdapter.java b/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControlAdapter.java index aa595a0..50449aa 100644 --- a/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControlAdapter.java +++ b/src/net/java/sip/communicator/service/neomedia/control/KeyFrameControlAdapter.java @@ -17,6 +17,13 @@ public class KeyFrameControlAdapter implements KeyFrameControl { /** + * The <tt>KeyFrameRequestee</tt>s made available by this + * <tt>KeyFrameControl</tt>. + */ + private List<KeyFrameRequestee> keyFrameRequestees + = new ArrayList<KeyFrameRequestee>(0); + + /** * The <tt>KeyFrameRequester</tt>s made available by this * <tt>KeyFrameControl</tt>. */ @@ -24,6 +31,12 @@ public class KeyFrameControlAdapter = new ArrayList<KeyFrameRequester>(0); /** + * An unmodifiable view of {@link #keyFrameRequestees} appropriate to be + * returned by {@link #getKeyFrameRequestees()}. + */ + private List<KeyFrameRequestee> unmodifiableKeyFrameRequestees; + + /** * An unmodifiable view of {@link #keyFrameRequesters} appropriate to be * returned by {@link #getKeyFrameRequesters()}. */ @@ -31,6 +44,50 @@ public class KeyFrameControlAdapter /** * Implements + * {@link KeyFrameControl#addKeyFrameRequestee(int, KeyFrameRequestee)}. + * + * {@inheritDoc} + */ + public void addKeyFrameRequestee( + int index, + KeyFrameRequestee keyFrameRequestee) + { + if (keyFrameRequestee == null) + throw new NullPointerException("keyFrameRequestee"); + synchronized (this) + { + if (!keyFrameRequestees.contains(keyFrameRequestee)) + { + List<KeyFrameRequestee> newKeyFrameRequestees + = new ArrayList<KeyFrameRequestee>( + keyFrameRequestees.size() + 1); + + newKeyFrameRequestees.addAll(keyFrameRequestees); + /* + * If this KeyFrameControl is to determine the index at which + * keyFrameRequestee is to be added according to its own + * internal logic, then it will prefer KeyFrameRequestee + * implementations from outside of neomedia rather than from its + * inside. + */ + if (-1 == index) + { + if (keyFrameRequestee.getClass().getName().contains( + ".neomedia.")) + index = newKeyFrameRequestees.size(); + else + index = 0; + } + newKeyFrameRequestees.add(index, keyFrameRequestee); + + keyFrameRequestees = newKeyFrameRequestees; + unmodifiableKeyFrameRequestees = null; + } + } + } + + /** + * Implements * {@link KeyFrameControl#addKeyFrameRequester(int, KeyFrameRequester)}. * * {@inheritDoc} @@ -74,6 +131,24 @@ public class KeyFrameControlAdapter } /** + * Implements {@link KeyFrameControl#getKeyFrameRequestees()}. + * + * {@inheritDoc} + */ + public List<KeyFrameRequestee> getKeyFrameRequestees() + { + synchronized (this) + { + if (unmodifiableKeyFrameRequestees == null) + { + unmodifiableKeyFrameRequestees + = Collections.unmodifiableList(keyFrameRequestees); + } + return unmodifiableKeyFrameRequestees; + } + } + + /** * Implements {@link KeyFrameControl#getKeyFrameRequesters()}. * * {@inheritDoc} @@ -92,6 +167,60 @@ public class KeyFrameControlAdapter } /** + * Implements {@link KeyFrameControl#keyFrameRequest()}. + * + * {@inheritDoc} + */ + public boolean keyFrameRequest() + { + for (KeyFrameRequestee keyFrameRequestee : getKeyFrameRequestees()) + { + try + { + if (keyFrameRequestee.keyFrameRequest()) + return true; + } + catch (Exception e) + { + /* + * A KeyFrameRequestee has malfunctioned, do not let it + * interfere with the others. + */ + } + } + return false; + } + + /** + * Implements + * {@link KeyFrameControl#removeKeyFrameRequestee(KeyFrameRequestee)}. + * + * {@inheritDoc} + */ + public boolean removeKeyFrameRequestee(KeyFrameRequestee keyFrameRequestee) + { + synchronized (this) + { + int index = keyFrameRequestees.indexOf(keyFrameRequestee); + + if (-1 != index) + { + List<KeyFrameRequestee> newKeyFrameRequestees + = new ArrayList<KeyFrameRequestee>(keyFrameRequestees); + + newKeyFrameRequestees.remove(index); + + keyFrameRequestees = newKeyFrameRequestees; + unmodifiableKeyFrameRequestees = null; + + return true; + } + else + return false; + } + } + + /** * Implements * {@link KeyFrameControl#removeKeyFrameRequester(KeyFrameRequester)}. * |