Skip to content

Commit

Permalink
PlatformPlayer: Add checks for Qualcomm's PureVoice format
Browse files Browse the repository at this point in the history
Ultra rare, and not likely to be supported at all, but it exists
and is used by a samsung version of 3D Hunting Grizzly. Might as
well notify of this format whenever it comes up.

Also, add array size checks on all conditionals.
  • Loading branch information
AShiningRay committed Dec 5, 2024
1 parent 29b7b05 commit 9aef335
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/org/recompile/mobile/PlatformPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,43 +106,50 @@ else if(contentType.equalsIgnoreCase("audio/mpeg") || contentType.equalsIgnoreCa
final byte[] data = new byte[stream.available()];
stream.read(data, 0, stream.available());

if(data[0] == 'M' && data[1] == 'T' && data[2] == 'h' && data[3] == 'd')
if(data.length >= 4 && data[0] == 'M' && data[1] == 'T' && data[2] == 'h' && data[3] == 'd')
{
Mobile.log(Mobile.LOG_WARNING, PlatformPlayer.class.getPackage().getName() + "." + PlatformPlayer.class.getSimpleName() + ": " + "Format is MIDI!");
player = new midiPlayer(new ByteArrayInputStream(data));
contentType = "audio/mid";
}
else if(data[0] == 'R' && data[1] == 'I' && data[2] == 'F' && data[3] == 'F')
else if (data.length >= 15 && data[8] == 'Q' && data[9] == 'L' && data[10] == 'C' && data[11] == 'M' && data[12] == 'f' && data[13] == 'm' && data[14] == 't')
{
// This is for Qualcomm's QCP format, it has to be checked before wav, because Qualcomm's PureVoice also has RIFF as its first bytes
Mobile.log(Mobile.LOG_WARNING, PlatformPlayer.class.getPackage().getName() + "." + PlatformPlayer.class.getSimpleName() + ": " + "Format is Qualcomm PureVoice! (not supported yet)");
player = new audioplayer();
contentType = "audio/qcp";
}
else if(data.length >= 4 && data[0] == 'R' && data[1] == 'I' && data[2] == 'F' && data[3] == 'F')
{
Mobile.log(Mobile.LOG_WARNING, PlatformPlayer.class.getPackage().getName() + "." + PlatformPlayer.class.getSimpleName() + ": " + "Format is WAV!");
player = new wavPlayer(new ByteArrayInputStream(data));
contentType = "audio/wav";
}
else if(data[0] == 'I' && data[1] == 'D' && data[2] == '3' || ((data[0] == (byte) 0xFF) && (data[1] & 0xE0) == 0xE0)) // Check for MPEG files WITH and WITHOUT the ID3 tag
else if(data.length >= 3 && data[0] == 'I' && data[1] == 'D' && data[2] == '3' || ((data[0] == (byte) 0xFF) && (data[1] & 0xE0) == 0xE0)) // Check for MPEG files WITH and WITHOUT the ID3 tag
{
Mobile.log(Mobile.LOG_WARNING, PlatformPlayer.class.getPackage().getName() + "." + PlatformPlayer.class.getSimpleName() + ": " + "Format is MPEG!");
player = new MP3Player(new ByteArrayInputStream(data));
contentType = "audio/mpeg";
}
else if(data[0] == 'M' && data[1] == 'M' && data[2] == 'M' && data[3] == 'D')
else if(data.length >= 4 && data[0] == 'M' && data[1] == 'M' && data[2] == 'M' && data[3] == 'D')
{
Mobile.log(Mobile.LOG_WARNING, PlatformPlayer.class.getPackage().getName() + "." + PlatformPlayer.class.getSimpleName() + ": " + "Format is SMAF/MMF! (not supported yet)");
player = new audioplayer();
contentType = "audio/mmf";
}
else if(data[0] == 'm' && data[1] == 'e' && data[2] == 'l' && data[3] == 'o')
else if(data.length >= 4 && data[0] == 'm' && data[1] == 'e' && data[2] == 'l' && data[3] == 'o')
{
Mobile.log(Mobile.LOG_WARNING, PlatformPlayer.class.getPackage().getName() + "." + PlatformPlayer.class.getSimpleName() + ": " + "Format is MFi! (not supported yet)");
player = new audioplayer();
contentType = "audio/mfi";
}
else if (data.length >= 6 && data[0] == '#' && data[1] == '!' && data[2] == 'A' && data[3] == 'M' && data[4] == 'R' && data[5] == '\n')
else if(data.length >= 6 && data[0] == '#' && data[1] == '!' && data[2] == 'A' && data[3] == 'M' && data[4] == 'R' && data[5] == '\n')
{
Mobile.log(Mobile.LOG_WARNING, PlatformPlayer.class.getPackage().getName() + "." + PlatformPlayer.class.getSimpleName() + ": " + "Format is AMR-NB! (not supported yet)");
player = new audioplayer();
contentType = "audio/amr";
}
else if (data.length >= 9 && data[0] == '#' && data[1] == '!' && data[2] == 'A' && data[3] == 'M' && data[4] == 'R' && data[5] == '-' && data[6] == 'W' && data[7] == 'B' && data[8] == '\n')
else if(data.length >= 9 && data[0] == '#' && data[1] == '!' && data[2] == 'A' && data[3] == 'M' && data[4] == 'R' && data[5] == '-' && data[6] == 'W' && data[7] == 'B' && data[8] == '\n')
{
Mobile.log(Mobile.LOG_WARNING, PlatformPlayer.class.getPackage().getName() + "." + PlatformPlayer.class.getSimpleName() + ": " + "Format is AMR-WB! (not supported yet)");
player = new audioplayer();
Expand Down

0 comments on commit 9aef335

Please sign in to comment.