Skip to content

Commit

Permalink
Merge pull request fyhertz#187 from DevFactory/release/collapsable-if…
Browse files Browse the repository at this point in the history
…-statements-should-be-merged-fix-1

Code quality fix - Collapsible "if" statements should be merged.
  • Loading branch information
Simon authored Mar 13, 2017
2 parents 94189f4 + 8312cf7 commit 197b569
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
14 changes: 6 additions & 8 deletions src/net/majorkernelpanic/streaming/audio/AACStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,12 @@ private void testADTS() throws IllegalStateException, IOException {

String key = PREF_PREFIX+"aac-"+mQuality.samplingRate;

if (mSettings!=null) {
if (mSettings.contains(key)) {
String[] s = mSettings.getString(key, "").split(",");
mQuality.samplingRate = Integer.valueOf(s[0]);
mConfig = Integer.valueOf(s[1]);
mChannel = Integer.valueOf(s[2]);
return;
}
if (mSettings!=null && mSettings.contains(key)) {
String[] s = mSettings.getString(key, "").split(",");
mQuality.samplingRate = Integer.valueOf(s[0]);
mConfig = Integer.valueOf(s[1]);
mChannel = Integer.valueOf(s[2]);
return;
}

final String TESTFILE = Environment.getExternalStorageDirectory().getPath()+"/spydroid-test.adts";
Expand Down
6 changes: 2 additions & 4 deletions src/net/majorkernelpanic/streaming/hw/EncoderDebugger.java
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,8 @@ private void convertToNV21(int k) {
stride = format.getInteger("stride");
if (stride<mWidth) stride = mWidth;
}
if (format.containsKey(MediaFormat.KEY_COLOR_FORMAT)) {
if (format.getInteger(MediaFormat.KEY_COLOR_FORMAT)>0) {
colorFormat = format.getInteger(MediaFormat.KEY_COLOR_FORMAT);
}
if (format.containsKey(MediaFormat.KEY_COLOR_FORMAT) && format.getInteger(MediaFormat.KEY_COLOR_FORMAT)>0) {
colorFormat = format.getInteger(MediaFormat.KEY_COLOR_FORMAT);
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/net/majorkernelpanic/streaming/rtcp/SenderReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,10 @@ public void update(int length, long rtpts) throws IOException {
now = SystemClock.elapsedRealtime();
delta += oldnow != 0 ? now-oldnow : 0;
oldnow = now;
if (interval>0) {
if (delta>=interval) {
// We send a Sender Report
send(System.nanoTime(), rtpts);
delta = 0;
}
if (interval>0 && delta>=interval) {
// We send a Sender Report
send(System.nanoTime(), rtpts);
delta = 0;
}

}
Expand Down
12 changes: 6 additions & 6 deletions src/net/majorkernelpanic/streaming/rtsp/RtspServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public void stop() {
try {
mListenerThread.kill();
for ( Session session : mSessions.keySet() ) {
if ( session != null ) {
if (session.isStreaming()) session.stop();
if ( session != null && session.isStreaming() ) {
session.stop();
}
}
} catch (Exception e) {
Expand All @@ -205,8 +205,8 @@ public void stop() {
/** Returns whether or not the RTSP server is streaming to some client(s). */
public boolean isStreaming() {
for ( Session session : mSessions.keySet() ) {
if ( session != null ) {
if (session.isStreaming()) return true;
if ( session != null && session.isStreaming() ) {
return true;
}
}
return false;
Expand All @@ -220,8 +220,8 @@ public boolean isEnabled() {
public long getBitrate() {
long bitrate = 0;
for ( Session session : mSessions.keySet() ) {
if ( session != null ) {
if (session.isStreaming()) bitrate += session.getBitrate();
if ( session != null && session.isStreaming() ) {
bitrate += session.getBitrate();
}
}
return bitrate;
Expand Down
8 changes: 3 additions & 5 deletions src/net/majorkernelpanic/streaming/video/H264Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,9 @@ private MP4Config testMediaCodecAPI() throws RuntimeException, IOException {
private MP4Config testMediaRecorderAPI() throws RuntimeException, IOException {
String key = PREF_PREFIX+"h264-mr-"+mRequestedQuality.framerate+","+mRequestedQuality.resX+","+mRequestedQuality.resY;

if (mSettings != null) {
if (mSettings.contains(key)) {
String[] s = mSettings.getString(key, "").split(",");
return new MP4Config(s[0],s[1],s[2]);
}
if (mSettings != null && mSettings.contains(key) ) {
String[] s = mSettings.getString(key, "").split(",");
return new MP4Config(s[0],s[1],s[2]);
}

if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
Expand Down

0 comments on commit 197b569

Please sign in to comment.