Skip to content
This repository
Browse code

Improvement for stream or transcode decision logic (thanks, StreamHD!)

  • Loading branch information...
commit ad8d98c7d7c022042f6f539a2393e79e2c0fa99b 1 parent c87afe6
Patrick Atoon authored January 03, 2012
22  src/main/java/net/pms/dlna/DLNAResource.java
@@ -542,14 +542,27 @@ public void addChild(DLNAResource child) {
542 542
 							}
543 543
 						}
544 544
 
  545
+						boolean hasSubsToTranscode = false;
  546
+
  547
+						if (!PMS.getConfiguration().isMencoderDisableSubs()) {
  548
+						    hasSubsToTranscode = (PMS.getConfiguration().getUseSubtitles() && child.isSrtFile()) || hasEmbeddedSubs;
  549
+						}
  550
+
  551
+						boolean isIncompatible = false;
  552
+
  553
+						// FIXME: Remove PS3 specific logic to support other renderers
  554
+						if (!parserV2 && !child.getExt().ps3compatible()) {
  555
+							isIncompatible = true;
  556
+						}
  557
+
545 558
 						// Force transcoding if
546 559
 						// 1- MediaInfo support detected the file was not matched with supported codec configs and no SkipTranscode extension forced by user
547 560
 						// or 2- ForceTranscode extension forced by user
548 561
 						// or 3- FFmpeg support and the file is not ps3 compatible (need to remove this ?) and no SkipTranscode extension forced by user
549 562
 						// or 4- There's some sub files or embedded subs to deal with and no SkipTranscode extension forced by user
550  
-						if (forceTranscode || !isSkipTranscode() && (forceTranscodeV2 || (!parserV2 && !child.getExt().ps3compatible()) || (PMS.getConfiguration().getUseSubtitles() && child.isSrtFile()) || hasEmbeddedSubs)) {
551  
-							child.setPlayer(pl);
552  
-							LOGGER.trace("Switching " + child.getName() + " to player: " + pl.toString());
  563
+						if (forceTranscode || !isSkipTranscode() && (forceTranscodeV2 || isIncompatible || hasSubsToTranscode)) {
  564
+						    child.setPlayer(pl);
  565
+						    LOGGER.trace("Switching " + child.getName() + " to player " + pl.toString() + " for transcoding");
553 566
 						}
554 567
 
555 568
 						if (child.getExt().isVideo()) {
@@ -580,6 +593,7 @@ public void addChild(DLNAResource child) {
580 593
 							}
581 594
 						}
582 595
 					} else if (!child.getExt().ps3compatible() && !child.isFolder()) {
  596
+						// FIXME: Remove PS3 specific logic to support other renderers
583 597
 						getChildren().remove(child);
584 598
 					}
585 599
 				}
@@ -589,6 +603,8 @@ public void addChild(DLNAResource child) {
589 603
 					newChild.setExt(newChild.getExt().getSecondaryFormat());
590 604
 					newChild.first = child;
591 605
 					child.second = newChild;
  606
+
  607
+					// FIXME: Remove PS3 specific logic to support other renderers
592 608
 					if (!newChild.getExt().ps3compatible() && newChild.getExt().getProfiles().size() > 0) {
593 609
 						newChild.setPlayer(PMS.get().getPlayer(newChild.getExt().getProfiles().get(0), newChild.getExt()));
594 610
 					}
2  src/main/java/net/pms/dlna/FileTranscodeVirtualFolder.java
@@ -106,6 +106,8 @@ public void resolve() {
106 106
 
107 107
 				// meskibob: I think it'd be a good idea to add a "Stream" option (for PS3 compatible containers) to the #Transcode# folder in addition to the current options already in there.
108 108
 				DLNAResource justStreamed = (DLNAResource) ref.clone();
  109
+
  110
+				// FIXME: Remove PS3 specific logic to support other renderers
109 111
 				if (justStreamed.getExt() != null && (justStreamed.getExt().ps3compatible() || justStreamed.isSkipTranscode())) {
110 112
 					justStreamed.setId(null);
111 113
 					justStreamed.setPlayer(null);
12  src/main/java/net/pms/formats/Format.java
@@ -67,6 +67,18 @@ public void setType(int type) {
67 67
 	}
68 68
 
69 69
 	public abstract String[] getId();
  70
+
  71
+	/**
  72
+	 * Returns whether or not a format can be handled by the PS3 natively.
  73
+	 * This means the format can be streamed to PS3 instead of having to be
  74
+	 * transcoded.
  75
+	 * <p>
  76
+	 * FIXME: There are many more renderers; mere PS3 compatibility doesn't
  77
+	 * cut it any more. Come up with a better solution, for example a
  78
+	 * RendererConfiguration.isStreamable(Format f).
  79
+	 * 
  80
+	 * @return True if the format can be handled by PS3, false otherwise.
  81
+	 */
70 82
 	public abstract boolean ps3compatible();
71 83
 	public abstract boolean transcodable();
72 84
 	public abstract ArrayList<Class<? extends Player>> getProfiles();

0 notes on commit ad8d98c

Please sign in to comment.
Something went wrong with that request. Please try again.