/** Create the DataSink. */ DataSink createDataSink(Processor p, MediaLocator outML) { DataSource ds; if ((ds = p.getDataOutput()) == null) { System.err.println( "Something is really wrong: the processor does not have an output DataSource"); return null; } DataSink dsink; try { System.err.println("- Create DataSink for: " + outML); dsink = Manager.createDataSink(ds, outML); dsink.open(); } catch (Exception e) { System.err.println("Cannot create the DataSink: " + e); return null; } return dsink; }
/** With the given processor info generated from matchTracks, build each of the processors. */ public boolean buildTracks(ProcInfo pInfo[]) { ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW); Processor p; for (int i = 0; i < pInfo.length; i++) { p = pInfo[i].p; p.setContentDescriptor(cd); // We are done with programming the processor. Let's just // realize the it. if (!waitForState(p, Controller.Realized)) { System.err.println("- Failed to realize the processor."); return false; } // Set the JPEG quality to .5. setJPEGQuality(p, 0.5f); PushBufferStream pbs[]; TrackInfo tInfo; int trackID; // Cheating. I should have checked the type of DataSource // returned. pInfo[i].ds = (PushBufferDataSource) p.getDataOutput(); pbs = pInfo[i].ds.getStreams(); // Find the matching data stream for the given track for audio. for (int type = AUDIO; type < MEDIA_TYPES; type++) { for (trackID = 0; trackID < pInfo[i].numTracksByType[type]; trackID++) { tInfo = pInfo[i].tracksByType[type][trackID]; tInfo.pbs = pbs[tInfo.idx]; } } } return true; }