Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libjitsi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZRTP
libjitsi
Commits
03ac531f
Commit
03ac531f
authored
10 years ago
by
Boris Grozev
Browse files
Options
Downloads
Patches
Plain Diff
Allows the MP3 encoder's buffer to be flushed.
parent
c2e05556
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/org/jitsi/impl/neomedia/codec/audio/mp3/JNIEncoder.java
+38
-5
38 additions, 5 deletions
src/org/jitsi/impl/neomedia/codec/audio/mp3/JNIEncoder.java
src/org/jitsi/service/neomedia/control/FlushableControl.java
+23
-0
23 additions, 0 deletions
src/org/jitsi/service/neomedia/control/FlushableControl.java
with
61 additions
and
5 deletions
src/org/jitsi/impl/neomedia/codec/audio/mp3/JNIEncoder.java
+
38
−
5
View file @
03ac531f
...
@@ -12,15 +12,20 @@
...
@@ -12,15 +12,20 @@
import
net.sf.fmj.media.*
;
import
net.sf.fmj.media.*
;
import
org.jitsi.impl.neomedia.codec.*
;
import
org.jitsi.impl.neomedia.codec.*
;
import
org.jitsi.service.neomedia.control.*
;
import
org.jitsi.util.*
;
import
org.jitsi.util.*
;
import
java.awt.*
;
/**
/**
* Implements a MP3 encoder using the native FFmpeg library.
* Implements a MP3 encoder using the native FFmpeg library.
*
*
* @author Lyubomir Marinov
* @author Lyubomir Marinov
* @author Boris Grozev
*/
*/
public
class
JNIEncoder
public
class
JNIEncoder
extends
AbstractCodec2
extends
AbstractCodec2
implements
FlushableControl
{
{
/**
/**
* The <tt>Logger</tt> used by the <tt>JNIEncoder</tt> class and its
* The <tt>Logger</tt> used by the <tt>JNIEncoder</tt> class and its
...
@@ -89,6 +94,11 @@ public class JNIEncoder
...
@@ -89,6 +94,11 @@ public class JNIEncoder
*/
*/
private
int
prevInputLength
;
private
int
prevInputLength
;
/**
* Synchronize access to <tt>prevInput</tt> and <tt>prevInputLength</tt>
*/
private
Object
prevInputSyncRoot
=
new
Object
();
/**
/**
* Initializes a new <tt>JNIEncoder</tt> instance.
* Initializes a new <tt>JNIEncoder</tt> instance.
*/
*/
...
@@ -97,12 +107,14 @@ public JNIEncoder()
...
@@ -97,12 +107,14 @@ public JNIEncoder()
super
(
"MP3 JNI Encoder"
,
AudioFormat
.
class
,
SUPPORTED_OUTPUT_FORMATS
);
super
(
"MP3 JNI Encoder"
,
AudioFormat
.
class
,
SUPPORTED_OUTPUT_FORMATS
);
inputFormats
=
SUPPORTED_INPUT_FORMATS
;
inputFormats
=
SUPPORTED_INPUT_FORMATS
;
addControl
(
this
);
}
}
/**
/**
* Implements {@link AbstractCodec
Ext
#doClose()}.
* Implements {@link AbstractCodec
2
#doClose()}.
*
*
* @see AbstractCodec
Ext
#doClose()
* @see AbstractCodec
2
#doClose()
*/
*/
@Override
@Override
protected
synchronized
void
doClose
()
protected
synchronized
void
doClose
()
...
@@ -127,7 +139,7 @@ protected synchronized void doClose()
...
@@ -127,7 +139,7 @@ protected synchronized void doClose()
*
*
* @throws ResourceUnavailableException if any of the resources that this
* @throws ResourceUnavailableException if any of the resources that this
* <tt>Codec</tt> needs to operate cannot be acquired
* <tt>Codec</tt> needs to operate cannot be acquired
* @see AbstractCodec
Ext
#doOpen()
* @see AbstractCodec
2
#doOpen()
*/
*/
@Override
@Override
protected
synchronized
void
doOpen
()
protected
synchronized
void
doOpen
()
...
@@ -200,11 +212,11 @@ protected synchronized void doOpen()
...
@@ -200,11 +212,11 @@ protected synchronized void doOpen()
}
}
/**
/**
* Implements {@link AbstractCodec
Ext
#doProcess(Buffer, Buffer)}.
* Implements {@link AbstractCodec
2
#doProcess(Buffer, Buffer)}.
*
*
* @param inputBuffer
* @param inputBuffer
* @param outputBuffer
* @param outputBuffer
* @see AbstractCodec
Ext
#doProcess(Buffer, Buffer)
* @see AbstractCodec
2
#doProcess(Buffer, Buffer)
*/
*/
@Override
@Override
protected
synchronized
int
doProcess
(
protected
synchronized
int
doProcess
(
...
@@ -215,6 +227,8 @@ protected synchronized int doProcess(
...
@@ -215,6 +227,8 @@ protected synchronized int doProcess(
int
inputLength
=
inputBuffer
.
getLength
();
int
inputLength
=
inputBuffer
.
getLength
();
int
inputOffset
=
inputBuffer
.
getOffset
();
int
inputOffset
=
inputBuffer
.
getOffset
();
synchronized
(
prevInputSyncRoot
)
{
if
((
prevInputLength
>
0
)
||
(
inputLength
<
frameSizeInBytes
))
if
((
prevInputLength
>
0
)
||
(
inputLength
<
frameSizeInBytes
))
{
{
int
newPrevInputLength
int
newPrevInputLength
...
@@ -288,5 +302,24 @@ protected synchronized int doProcess(
...
@@ -288,5 +302,24 @@ protected synchronized int doProcess(
else
else
return
BUFFER_PROCESSED_OK
;
return
BUFFER_PROCESSED_OK
;
}
}
}
//synchronized
}
@Override
public
void
flush
()
{
synchronized
(
prevInputSyncRoot
)
{
prevInputLength
=
0
;
}
}
/**
* Implements {@link javax.media.Control#getControlComponent()}.
*/
@Override
public
Component
getControlComponent
()
{
return
null
;
}
}
}
}
This diff is collapsed.
Click to expand it.
src/org/jitsi/service/neomedia/control/FlushableControl.java
0 → 100644
+
23
−
0
View file @
03ac531f
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package
org.jitsi.service.neomedia.control
;
import
javax.media.*
;
/**
* An interface which allows to flush a buffer.
*
* @author Boris Grozev
*/
public
interface
FlushableControl
extends
Control
{
/**
* Flushes the buffer.
*/
public
void
flush
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment