当前位置: 首页>>代码示例>>Java>>正文


Java TrackControl类代码示例

本文整理汇总了Java中javax.media.control.TrackControl的典型用法代码示例。如果您正苦于以下问题:Java TrackControl类的具体用法?Java TrackControl怎么用?Java TrackControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TrackControl类属于javax.media.control包,在下文中一共展示了TrackControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTrackFormats

import javax.media.control.TrackControl; //导入依赖的package包/类
/**
    * Set the target transcode format on the processor.
    */
   boolean setTrackFormats(Processor p, Format fmts[]) {

if (fmts.length == 0)
    return true;

TrackControl tcs[];

if ((tcs = p.getTrackControls()) == null) {
    // The processor does not support any track control.
    System.err.println("The Processor cannot transcode the tracks to the given formats");
    return false;
}

	for (int i = 0; i < fmts.length; i++) {	

    System.err.println("- set track format to: " + fmts[i]);

    if (!setEachTrackFormat(p, tcs, fmts[i])) {
	System.err.println("Cannot transcode any track to: " + fmts[i]);
	return false;
    }
}

return true;
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:29,代码来源:Transcode.java

示例2: tryTranscode

import javax.media.control.TrackControl; //导入依赖的package包/类
/**
    * Try different transcoded formats for concatenation.
    */
   public boolean tryTranscode(ProcInfo pInfo[], int procID, int type, 
	int trackID, Format candidate) {

if (procID >= pInfo.length)
    return true;

boolean matched = false;
TrackControl tc = pInfo[procID].tracksByType[type][trackID].tc;
Format supported[] = tc.getSupportedFormats(); 

for (int i = 0; i < supported.length; i++) {
    if (candidate.matches(supported[i]) &&
	tryTranscode(pInfo, procID+1, type, trackID, candidate)) {
	matched = true;
	break;
    }
}

return matched;
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:24,代码来源:Concat.java

示例3: transcodeMPEGToRaw

import javax.media.control.TrackControl; //导入依赖的package包/类
/**
    * Transcode the MPEG audio to linear and video to JPEG so
    * we can do the splitting.
    */
   void transcodeMPEGToRaw(Processor p) {

TrackControl tc[] = p.getTrackControls();
AudioFormat afmt;

for (int i = 0; i < tc.length; i++) {
    if (tc[i].getFormat() instanceof VideoFormat)
	tc[i].setFormat(new VideoFormat(VideoFormat.JPEG));
    else if (tc[i].getFormat() instanceof AudioFormat) {
	afmt = (AudioFormat)tc[i].getFormat();
	tc[i].setFormat(new AudioFormat(AudioFormat.LINEAR,
					afmt.getSampleRate(), 
					afmt.getSampleSizeInBits(),
					afmt.getChannels()));
    }
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:22,代码来源:Split.java

示例4: getMyTracks

import javax.media.control.TrackControl; //导入依赖的package包/类
private void getMyTracks() {
	Format format;
	TrackControl[] track = p.getTrackControls();
	track_amount = track.length;
	trackInfos = new String[track_amount];
	Time t = p.getDuration();
	trackTime = t.getSeconds();

	for (int i = 0; i < track_amount; i++) {
		format = track[i].getFormat();
		trackInfos[i] = format.toString();
		if (format instanceof VideoFormat) {
			videoTrack = true;
		}
		if (format instanceof AudioFormat) {
			audioTrack = true;
		}
	}
	read = true;
}
 
开发者ID:mloobo,项目名称:Dolphin-Streaming-Server,代码行数:21,代码来源:InfoArchivo.java

示例5: setHandlers

import javax.media.control.TrackControl; //导入依赖的package包/类
/**
 * Set appropriate handlers for the audio and video tracks.
 * We create our own handlers, which in turn will call the
 * handlers provided to us in the constructor of this class.
 */
private void setHandlers()
{
    TrackControl controls[] = processor.getTrackControls();
    int nControls = controls.length;
    int i;
    for (i=0;i<nControls;i++) {
        Format format = controls[i].getFormat();
        try {
            if (format instanceof VideoFormat) {
                videoRenderer = new VideoRenderer(videoHandler);
                controls[i].setRenderer(videoRenderer);
            } else if (format instanceof AudioFormat) {
                controls[i].setRenderer(new AudioRenderer());
            } else {
                System.err.println("Unknown track type");
            }
        } catch (UnsupportedPlugInException e) {
            System.err.println("Got exception "+e);
        }
    }
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:27,代码来源:MovieDecoder.java

示例6: setTrackFormats

import javax.media.control.TrackControl; //导入依赖的package包/类
/**
    * Set the target transcode format on the processor.
    */
   boolean setTrackFormats(Processor p) {

Format supported[];

TrackControl [] tracks = p.getTrackControls();

// Do we have at least one track?
if (tracks == null || tracks.length < 1) {
    System.err.println("Couldn't find tracks in processor");
    return false;
}

for (int i = 0; i < tracks.length; i++) {
    if (tracks[i].isEnabled()) {
	supported = tracks[i].getSupportedFormats();
	if (supported.length > 0) {
	    tracks[i].setFormat(supported[0]);
	} else {
	    System.err.println("Cannot transcode track [" + i + "]");
	    tracks[i].setEnabled(false);
	    return false;
	}
    } else {
	tracks[i].setEnabled(false);		
	return false;
    }
}
return true;
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:33,代码来源:RTPExport.java

示例7: setEachTrackFormat

import javax.media.control.TrackControl; //导入依赖的package包/类
/**
    * We'll loop through the tracks and try to find a track
    * that can be converted to the given format.
    */
   boolean setEachTrackFormat(Processor p, TrackControl tcs[], Format fmt) {

Format supported[];
Format f;

for (int i = 0; i < tcs.length; i++) {

    supported = tcs[i].getSupportedFormats();

    if (supported == null)
	continue;

    for (int j = 0; j < supported.length; j++) {

	if (fmt.matches(supported[j]) &&
	    (f = fmt.intersects(supported[j])) != null &&
	    tcs[i].setFormat(f) != null) {

	    // Success.
	    return true;
	}
    }
}

return false;
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:31,代码来源:Transcode.java

示例8: checkTrackFormats

import javax.media.control.TrackControl; //导入依赖的package包/类
/**
    * Transcode the MPEG audio to linear and video to JPEG so
    * we can do the cutting.
    */
   void checkTrackFormats(Processor p) {

TrackControl tc[] = p.getTrackControls();
VideoFormat mpgVideo = new VideoFormat(VideoFormat.MPEG);
AudioFormat rawAudio = new AudioFormat(AudioFormat.LINEAR);

for (int i = 0; i < tc.length; i++) {
    Format preferred = null;

    if (tc[i].getFormat().matches(mpgVideo)) {
	preferred = new VideoFormat(VideoFormat.JPEG);
    } else if (tc[i].getFormat() instanceof AudioFormat &&
	     !tc[i].getFormat().matches(rawAudio)) {
	preferred = rawAudio;
    }

    if (preferred != null) {
	Format supported[] = tc[i].getSupportedFormats();
	Format selected = null;

	for (int j = 0; j < supported.length; j++) {
	    if (supported[j].matches(preferred)) {
		selected = supported[j];
		break;
	    }
	}

	if (selected != null) {
	    System.err.println("  Transcode:");
	    System.err.println("     from: " + tc[i].getFormat());
	    System.err.println("     to: " + selected);
	    tc[i].setFormat(selected);
	}
    }
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:41,代码来源:Cut.java

示例9: SuperCutDataSource

import javax.media.control.TrackControl; //导入依赖的package包/类
public SuperCutDataSource(Processor p, MediaLocator ml, 
		long start[], long end[]) {
    this.p = p;
    this.ml = ml;
    this.ds = (PushBufferDataSource)p.getDataOutput();

    TrackControl tcs[] = p.getTrackControls();
    PushBufferStream pbs[] = ds.getStreams();

    streams = new SuperCutStream[pbs.length];
    for (int i = 0; i < pbs.length; i++) {
	streams[i] = new SuperCutStream(tcs[i], pbs[i], start, end);
    }
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:15,代码来源:Cut.java

示例10: SuperCutStream

import javax.media.control.TrackControl; //导入依赖的package包/类
public SuperCutStream(TrackControl tc, PushBufferStream pbs, 
		long start[], long end[]) {
    this.tc = tc;
    this.pbs = pbs;
    this.start = start;
    this.end = end;
    startReached = new boolean[start.length];
    endReached = new boolean[end.length];
    for (int i = 0; i < start.length; i++) {
	startReached[i] = endReached[i] = false;
    }
    buffer = new Buffer();
    pbs.setTransferHandler(this);
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:15,代码来源:Cut.java

示例11: process

import javax.media.control.TrackControl; //导入依赖的package包/类
public void process(String recordingFile, String movieFile) throws Exception {

      MediaLocator mediaLocator = new MediaLocator(new File(movieFile).toURI()
            .toURL());
      PlayerDataSource playerDataSource = new PlayerDataSource(recordingFile);
      Processor processor = Manager.createProcessor(playerDataSource);
      processor.addControllerListener(this);
      processor.configure();

      if (!waitForState(processor, Processor.Configured)) {
         System.err.println("Failed to configure the processor.");
         return;
      }

      processor.setContentDescriptor(new ContentDescriptor(
            FileTypeDescriptor.QUICKTIME));

      TrackControl trackControl[] = processor.getTrackControls();
      Format format[] = trackControl[0].getSupportedFormats();
      trackControl[0].setFormat(format[0]);
      processor.realize();
      if (!waitForState(processor, Processor.Realized)) {
         System.err.println("Failed to realize the processor.");
         return;
      }

      DataSource dataSource = processor.getDataOutput();
      DataSink dataSink = Manager.createDataSink(dataSource, mediaLocator);
      dataSink.open();
      processor.start();
      dataSink.start();
      waitForFileDone();
      dataSink.close();
      processor.removeControllerListener(this);
   }
 
开发者ID:openwarrior,项目名称:java-screen-recorder,代码行数:36,代码来源:RecordingConverter.java

示例12: controllerUpdate

import javax.media.control.TrackControl; //导入依赖的package包/类
@Override
public void controllerUpdate(ControllerEvent p0) {
	if (p0 instanceof ConfigureCompleteEvent) {
		ContentDescriptor cd = new ContentDescriptor(
				ContentDescriptor.RAW_RTP);
		processor.setContentDescriptor(cd);
		Format format;
		TrackControl track[] = processor.getTrackControls();
		int numPistas=track.length;
		for(int i=0;i<numPistas;i++){
			format = track[i].getFormat();

			if (format instanceof VideoFormat) {
				VideoFormat v = (VideoFormat) track[i].getFormat();
				setMyVideoFormat(v, track[i]);
			}
			if (format instanceof AudioFormat) {
				AudioFormat a = (AudioFormat) track[i].getFormat();
				setMyAudioFormat(a, track[i]);
			}
		}
		processor.realize();
	}

	if (p0 instanceof RealizeCompleteEvent) {
		try {
			ds = processor.getDataOutput();
			createMyRTPManager();
		} catch (NotRealizedError ex) {
			myEx(null, ex.getMessage());
		}
	}

	if (p0 instanceof EndOfMediaEvent) {
		closeMyStream();
		endofMedia = true;
	}
}
 
开发者ID:mloobo,项目名称:Dolphin-Streaming-Server,代码行数:39,代码来源:UnicastRtpWebcam.java

示例13: tryMatch

import javax.media.control.TrackControl; //导入依赖的package包/类
/**
    * Try matching the data formats and find common ones for concatenation.
    */
   public boolean tryMatch(ProcInfo pInfo[], int type, int trackID) {

TrackControl tc = pInfo[0].tracksByType[type][trackID].tc;
Format origFmt = tc.getFormat();
Format newFmt, oldFmt;
Format supported[] = tc.getSupportedFormats(); 

for (int i = 0; i < supported.length; i++) {

    if (supported[i] instanceof AudioFormat) {
	// If it's not the original format, then for audio, we'll
	// only do linear since it's more accurate to compute the
	// audio times.
	if (!supported[i].matches(tc.getFormat()) &&
	    !supported[i].getEncoding().equalsIgnoreCase(AudioFormat.LINEAR))
	    continue;
    }

    if (tryTranscode(pInfo, 1, type, trackID, supported[i])) {

	// We've found the right format to transcode all the
	// tracks to.  We'll set it on the corresponding
	// TrackControl on each processor.

	for (int j = 0; j < pInfo.length; j++) {
	    tc = pInfo[j].tracksByType[type][trackID].tc;
	    oldFmt = tc.getFormat();
	    newFmt = supported[i];

	    // Check if it requires transcoding.
	    if (!oldFmt.matches(newFmt)) {
		if (!transcodeMsg) {
		    transcodeMsg = true;
		    System.err.println(TRANSCODE_MSG);
		}

		System.err.println("- Transcoding: " + pInfo[j].ml);
		System.err.println("  " + oldFmt);
		System.err.println("           to:");
		System.err.println("  " + newFmt);
	    } 

	    // For video, check if it requires scaling.
	    if (oldFmt instanceof VideoFormat) {
		Dimension newSize = ((VideoFormat)origFmt).getSize();
		Dimension oldSize = ((VideoFormat)oldFmt).getSize();

		if (oldSize != null && !oldSize.equals(newSize)) {
		    // It requires scaling.

		    if (!transcodeMsg) {
			transcodeMsg = true;
			System.err.println(TRANSCODE_MSG);
		    }
		    System.err.println("- Scaling: " + pInfo[j].ml);
		    System.err.println("  from: " + oldSize.width + 
					" x " + oldSize.height);
		    System.err.println("  to: " + newSize.width + 
					" x " + newSize.height);
		    newFmt = (new VideoFormat(null, 
				newSize, 
				Format.NOT_SPECIFIED,
				null,
				Format.NOT_SPECIFIED)).intersects(newFmt);
		}
	    }
	    tc.setFormat(newFmt);
	}

	return true;
    }
}

return false;

   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:80,代码来源:Concat.java

示例14: controllerUpdate

import javax.media.control.TrackControl; //导入依赖的package包/类
public void controllerUpdate(ControllerEvent p0) {
	if (p0 instanceof ConfigureCompleteEvent) {
		Format format;
		boolean encodingOK = false;

		TrackControl track[] = processor.getTrackControls();
		ContentDescriptor cd = new ContentDescriptor(
				ContentDescriptor.RAW_RTP);
		processor.setContentDescriptor(cd);
		format = track[prepare_track].getFormat();

		if (format instanceof VideoFormat) {
			VideoFormat v = (VideoFormat) track[prepare_track].getFormat();
			encodingOK = setMyVideoFormat(v, track[prepare_track]);
			if(HiloCliente.DEBUG){
				System.out.println("Pista "+prepare_track+" es de Video");
			}
		}
		if (format instanceof AudioFormat) {
			AudioFormat a = (AudioFormat) track[prepare_track].getFormat();
			encodingOK = setMyAudioFormat(a, track[prepare_track]);
			if(HiloCliente.DEBUG){
				System.out.println("Pista "+prepare_track+" es de Audio");
			}
		}

		if (encodingOK) {
			for (int i = 0; i < track.length; i++) {
				if (i != prepare_track) {
					track[i].setEnabled(false);
				}
			}
			processor.realize();
		}
	}

	if (p0 instanceof RealizeCompleteEvent) {
		try {
			ds = processor.getDataOutput();
			createMyRTPManager();
		} catch (NotRealizedError ex) {
			myEx(null, ex.getMessage());
		}
	}

	if (p0 instanceof EndOfMediaEvent) {
		closeMyStream();
		endofMedia = true;
	}
}
 
开发者ID:mloobo,项目名称:Dolphin-Streaming-Server,代码行数:51,代码来源:UnicastRtp.java

示例15: setMyVideoFormat

import javax.media.control.TrackControl; //导入依赖的package包/类
protected boolean setMyVideoFormat(VideoFormat v, TrackControl track) {
	boolean found = false;
	
	if(HiloCliente.DEBUG){
		Format[] supported = track.getSupportedFormats();
		for (int n = 0; n < supported.length; n++)
		    System.out.println("Formato de Video soportados: " + supported[n]);
	}
	
	if (v.isSameEncoding(VideoFormat.MPEG)) {
		((FormatControl) track).setFormat(new VideoFormat(
				VideoFormat.MPEG_RTP));
		found = true;
	}
	if (v.isSameEncoding(VideoFormat.JPEG_RTP)) {// para la webcam
		((FormatControl) track).setFormat(new VideoFormat(
				VideoFormat.JPEG_RTP));
		found = true;
	}
	if (v.isSameEncoding(VideoFormat.H263)) {
		((FormatControl) track).setFormat(new VideoFormat(
				VideoFormat.H263_RTP));
		found = true;
	}
	if (v.isSameEncoding(VideoFormat.JPEG)) {
		((FormatControl) track).setFormat(new VideoFormat(
				VideoFormat.JPEG_RTP));
		found = true;
	}
	if (v.isSameEncoding(VideoFormat.MJPG)) {
		((FormatControl) track).setFormat(new VideoFormat(
				VideoFormat.JPEG_RTP));
		found = true;
	}
	if (v.isSameEncoding(VideoFormat.YUV)) {// para la webcam
		((FormatControl) track).setFormat(new VideoFormat(
				VideoFormat.JPEG_RTP));
		found = true;
	}
	if (v.isSameEncoding(VideoFormat.RGB)) {// para el escritorio
		((FormatControl) track).setFormat(new VideoFormat(
				VideoFormat.JPEG_RTP));
		found = true;
	}	
	
	if(HiloCliente.DEBUG){
		String s="";
		if(found){
			s="Formato de video encontrado ("+v.toString()+"). " +
					"\nSe transforma a ("+((FormatControl) track).getFormat().toString()+").";
		}else{
			s="Formato de video ("+v.toString()+") NO encontrado.";
		}
		System.out.println(s);
	}
	
	track.setEnabled(found);
	return found;
}
 
开发者ID:mloobo,项目名称:Dolphin-Streaming-Server,代码行数:60,代码来源:UnicastRtp.java


注:本文中的javax.media.control.TrackControl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。