From 9bf6e95e0b6943fa2476ac7aa1e99b397419f614 Mon Sep 17 00:00:00 2001 From: Diego Waxemberg Date: Sun, 29 Dec 2013 11:53:16 -0500 Subject: [PATCH] Added javadoc to the audio/video binding classes --- .../limelight/binding/PlatformBinding.java | 17 +++++++++++ .../binding/audio/JavaxAudioRenderer.java | 18 ++++++++++++ .../video/SwingCpuDecoderRenderer.java | 28 +++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/src/com/limelight/binding/PlatformBinding.java b/src/com/limelight/binding/PlatformBinding.java index e9cd61b..c139e2b 100644 --- a/src/com/limelight/binding/PlatformBinding.java +++ b/src/com/limelight/binding/PlatformBinding.java @@ -8,11 +8,24 @@ import com.limelight.binding.video.SwingCpuDecoderRenderer; import com.limelight.nvstream.av.audio.AudioRenderer; import com.limelight.nvstream.av.video.VideoDecoderRenderer; +/** + * Used for platform-specific video/audio bindings. + * @author Cameron Gutman + */ public class PlatformBinding { + /** + * Gets an instance of a video decoder/renderer. + * @return a video decoder and renderer + */ public static VideoDecoderRenderer getVideoDecoderRenderer() { return new SwingCpuDecoderRenderer(); } + /** + * Gets the name of this device. + *
Currently, the hostname of the system. + * @return the name of this device + */ public static String getDeviceName() { try { return InetAddress.getLocalHost().getHostName(); @@ -21,6 +34,10 @@ public class PlatformBinding { } } + /** + * Gets an instance of an audio decoder/renderer. + * @return an audio decoder and renderer + */ public static AudioRenderer getAudioRenderer() { return new JavaxAudioRenderer(); } diff --git a/src/com/limelight/binding/audio/JavaxAudioRenderer.java b/src/com/limelight/binding/audio/JavaxAudioRenderer.java index e6f94f2..b28e3e4 100644 --- a/src/com/limelight/binding/audio/JavaxAudioRenderer.java +++ b/src/com/limelight/binding/audio/JavaxAudioRenderer.java @@ -11,10 +11,20 @@ import javax.sound.sampled.SourceDataLine; import com.limelight.nvstream.av.audio.AudioRenderer; import com.limelight.nvstream.av.audio.OpusDecoder; +/** + * Audio renderer implementation + * @author Cameron Gutman + */ public class JavaxAudioRenderer implements AudioRenderer { private SourceDataLine soundLine; + /** + * Takes some audio data and writes it out to the renderer. + * @param pcmData the array that contains the audio data + * @param offset the offset at which the data starts in the array + * @param length the length of data to be rendered + */ @Override public void playDecodedAudio(short[] pcmData, int offset, int length) { if (soundLine != null) { @@ -29,6 +39,9 @@ public class JavaxAudioRenderer implements AudioRenderer { } } + /** + * Callback for when the stream session is closing and the audio renderer should stop. + */ @Override public void streamClosing() { if (soundLine != null) { @@ -36,6 +49,11 @@ public class JavaxAudioRenderer implements AudioRenderer { } } + /** + * The callback for the audio stream being initialized and starting to receive. + * @param channelCount the number of channels in the audio + * @param sampleRate the sample rate for the audio. + */ @Override public void streamInitialized(int channelCount, int sampleRate) { AudioFormat audioFormat = new AudioFormat(sampleRate, 16, channelCount, true, true); diff --git a/src/com/limelight/binding/video/SwingCpuDecoderRenderer.java b/src/com/limelight/binding/video/SwingCpuDecoderRenderer.java index f31fca3..8183262 100644 --- a/src/com/limelight/binding/video/SwingCpuDecoderRenderer.java +++ b/src/com/limelight/binding/video/SwingCpuDecoderRenderer.java @@ -12,6 +12,10 @@ import com.limelight.nvstream.av.DecodeUnit; import com.limelight.nvstream.av.video.VideoDecoderRenderer; import com.limelight.nvstream.av.video.cpu.AvcDecoder; +/** + * Implementation of a video decoder and renderer. + * @author Cameron Gutman + */ public class SwingCpuDecoderRenderer implements VideoDecoderRenderer { private Thread rendererThread; @@ -28,6 +32,13 @@ public class SwingCpuDecoderRenderer implements VideoDecoderRenderer { // Only sleep if the difference is above this value private static final int WAIT_CEILING_MS = 8; + /** + * Sets up the decoder and renderer to render video at the specified dimensions + * @param width the width of the video to render + * @param height the height of the video to render + * @param renderTarget what to render the video onto + * @param drFlags flags for the decoder and renderer + */ @Override public void setup(int width, int height, Object renderTarget, int drFlags) { this.targetFps = 30; @@ -62,6 +73,9 @@ public class SwingCpuDecoderRenderer implements VideoDecoderRenderer { System.out.println("Using software decoding"); } + /** + * Starts the decoding and rendering of the video stream on a new thread + */ @Override public void start() { rendererThread = new Thread() { @@ -112,10 +126,16 @@ public class SwingCpuDecoderRenderer implements VideoDecoderRenderer { rendererThread.start(); } + /* + * Computes the amount of time to display a certain frame + */ private long computePresentationTimeMs(int frameRate) { return System.currentTimeMillis() + (1000 / frameRate); } + /** + * Stops the decoding and rendering of the video stream. + */ @Override public void stop() { rendererThread.interrupt(); @@ -125,11 +145,19 @@ public class SwingCpuDecoderRenderer implements VideoDecoderRenderer { } catch (InterruptedException e) { } } + /** + * Releases resources held by the decoder. + */ @Override public void release() { AvcDecoder.destroy(); } + /** + * Give a unit to be decoded to the decoder. + * @param decodeUnit the unit to be decoded + * @return true if the unit was decoded successfully, false otherwise + */ @Override public boolean submitDecodeUnit(DecodeUnit decodeUnit) { byte[] data;