|
From: jreichen <jre...@us...> - 2011-04-09 00:22:31
|
Update of /cvsroot/sageplugins/MediaStreaming/src/sagex/streaming/httpls/segment
In directory vz-cvs-3.sog:/tmp/cvs-serv9939/src/sagex/streaming/httpls/segment
Modified Files:
SegmenterProcess.java
Log Message:
- Calculate aspect ratio from width and height if it's not provided by SageTV metadata
- Add support for Android and Lavf (ffmpeg-based players such as VPlayer and Mirage) User-Agents. This does not necessarily mean these will immediately work in clients that use this service. Those must be fixed separately by their developers.
- Return more meaningful errors if Quality or User-Agent parameters are invalid.
Index: SegmenterProcess.java
===================================================================
RCS file: /cvsroot/sageplugins/MediaStreaming/src/sagex/streaming/httpls/segment/SegmenterProcess.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SegmenterProcess.java 15 Jan 2011 21:26:03 -0000 1.3
--- SegmenterProcess.java 9 Apr 2011 00:22:28 -0000 1.4
***************
*** 389,393 ****
// TODO TN2224 for qualities, different for iPad vs iPhone/iPod touch
String size = "400x300";
! if (userAgent.contains("iPhone") || userAgent.contains("iPod") || userAgent.length() == 0)
{
// 16:9
--- 389,396 ----
// TODO TN2224 for qualities, different for iPad vs iPhone/iPod touch
String size = "400x300";
! if (userAgent.contains("Lavf") || // assume Android's VPlayer or Mirage (or any ffmpeg-based player)
! userAgent.contains("Android") ||
! userAgent.contains("iPhone") || userAgent.contains("iPod") ||
! userAgent.length() == 0)
{
// 16:9
***************
*** 428,431 ****
--- 431,438 ----
qualityMap.put("150", s6);
}
+ else
+ {
+ throw new IllegalArgumentException("Unsupported User-Agent header: " + userAgent);
+ }
String[] currentQuality = qualityMap.get(quality);
***************
*** 433,437 ****
if (currentQuality == null)
{
! throw new IllegalArgumentException("Invalid quality argument");
}
--- 440,444 ----
if (currentQuality == null)
{
! throw new IllegalArgumentException("Invalid quality argument: " + quality);
}
***************
*** 457,460 ****
--- 464,490 ----
Object mediaFile = MediaFileAPI.GetMediaFileForFilePath(inputFile);
String aspect = MediaFileAPI.GetMediaFileMetadata(mediaFile, "Format.Video.Aspect");
+ if ((aspect == null) || (aspect.trim().length() == 0))
+ {
+ aspect = null;
+ String videoWidth = MediaFileAPI.GetMediaFileMetadata(mediaFile, "Format.Video.Width");
+ String videoHeight = MediaFileAPI.GetMediaFileMetadata(mediaFile, "Format.Video.Height");
+
+ if ((videoWidth != null) && (videoWidth.trim().length() != 0) &&
+ (videoHeight != null) && (videoHeight.trim().length() != 0))
+ {
+ try
+ {
+ Double widthDouble = Double.valueOf(videoWidth);
+ Double heightDouble = Double.valueOf(videoHeight);
+ aspect = Double.toString(widthDouble / heightDouble);
+ }
+ catch (NumberFormatException e)
+ {
+ Log.info(e.getMessage());
+ Log.ignore(e);
+ }
+ }
+
+ }
isCurrentlyRecording = MediaFileAPI.IsFileCurrentlyRecording(mediaFile);
***************
*** 500,504 ****
// "-cropbottom", "0",
params.add("-s"); params.add(currentQuality[0]);
! params.add("-aspect"); params.add(aspect);
params.add("-y");
params.add("-f"); params.add("mpegts");
--- 530,537 ----
// "-cropbottom", "0",
params.add("-s"); params.add(currentQuality[0]);
! if (aspect != null)
! {
! params.add("-aspect"); params.add(aspect);
! }
params.add("-y");
params.add("-f"); params.add("mpegts");
***************
*** 511,515 ****
params.add("-qmax"); params.add("48");
params.add("-qmin"); params.add("2");
! params.add("-r"); params.add("29.97");
// "-acodec", "libmp3lame",
params.add("-vol"); params.add("1024");
--- 544,548 ----
params.add("-qmax"); params.add("48");
params.add("-qmin"); params.add("2");
! params.add("-r"); params.add("29.97"); // 25
// "-acodec", "libmp3lame",
params.add("-vol"); params.add("1024");
|