-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Important bug fixes, for RtpSocket and AAC streaming
- Loading branch information
fyhertz
committed
Aug 20, 2013
1 parent
7d8931f
commit bd1f006
Showing
13 changed files
with
206 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/net/majorkernelpanic/streaming/audio/AudioQuality.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (C) 2011-2013 GUIGUI Simon, [email protected] | ||
* | ||
* This file is part of Spydroid (http://code.google.com/p/spydroid-ipcamera/) | ||
* | ||
* Spydroid is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This source code is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this source code; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
package net.majorkernelpanic.streaming.audio; | ||
|
||
/** | ||
* A class that represents the quality of an audio stream. | ||
*/ | ||
public class AudioQuality { | ||
|
||
/** Default audio stream quality. */ | ||
public final static AudioQuality DEFAULT_AUDIO_QUALITY = new AudioQuality(8000,32000); | ||
|
||
/** Represents a quality for a video stream. */ | ||
public AudioQuality() {} | ||
|
||
/** | ||
* Represents a quality for an audio stream. | ||
* @param samplingRate The sampling rate | ||
* @param bitRate The bitrate in bit per seconds | ||
*/ | ||
public AudioQuality(int samplingRate, int bitRate) { | ||
this.samplingRate = samplingRate; | ||
this.bitRate = bitRate; | ||
} | ||
|
||
public int samplingRate = 0; | ||
public int bitRate = 0; | ||
|
||
public boolean equals(AudioQuality quality) { | ||
if (quality==null) return false; | ||
return (quality.samplingRate == this.samplingRate & | ||
quality.bitRate == this.bitRate); | ||
} | ||
|
||
public AudioQuality clone() { | ||
return new AudioQuality(samplingRate, bitRate); | ||
} | ||
|
||
public static AudioQuality parseQuality(String str) { | ||
AudioQuality quality = new AudioQuality(0,0); | ||
if (str != null) { | ||
String[] config = str.split("-"); | ||
try { | ||
quality.bitRate = Integer.parseInt(config[0])*1000; // conversion to bit/s | ||
quality.samplingRate = Integer.parseInt(config[1]); | ||
} | ||
catch (IndexOutOfBoundsException ignore) {} | ||
} | ||
return quality; | ||
} | ||
|
||
public static AudioQuality merge(AudioQuality audioQuality, AudioQuality withAudioQuality) { | ||
if (withAudioQuality != null && audioQuality != null) { | ||
if (audioQuality.samplingRate==0) audioQuality.samplingRate = withAudioQuality.samplingRate; | ||
if (audioQuality.bitRate==0) audioQuality.bitRate = withAudioQuality.bitRate; | ||
} | ||
return audioQuality; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.