Package javax.media.control

Examples of javax.media.control.TrackControl


     * Try to match all the tracks and find common formats to concatenate
     * the tracks.  A database of results will be generated.
     */
    public boolean matchTracks(ProcInfo pInfo[], ContentDescriptor cd) {

  TrackControl tcs[];

  Vector aTracks, vTracks;
  int aIdx, vIdx;
  int i, j, type;
  TrackInfo tInfo;
View Full Code Here


    /**
     * 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;
      }
  }
View Full Code Here

  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;
View Full Code Here

      // Set the output content descriptor to QuickTime.
      processor.setContentDescriptor(new ContentDescriptor(FileTypeDescriptor.QUICKTIME));

      // Query for the processor for supported formats.
      // Then set it on the processor.
      TrackControl trackControls[] = processor.getTrackControls();
      Format format[] = trackControls [0].getSupportedFormats();
      if (format == null || format.length <= 0) {
        throw new IOException("The mux does not support the input format: " + trackControls [0].getFormat());
      }
View Full Code Here

                    "Failed to obtain track controls from the processor.");
        }

        // Search for the track control for the video track (vs. audio).
        // FIXME: We want the audio track too on a separate output, maybe.
        TrackControl videoTrack = null;

        for (int i = 0; i < trackControls.length; i++) {
            if (trackControls[i].getFormat() instanceof VideoFormat) {
                videoTrack = trackControls[i];
                break;
            }
        }

        // If the previous loop goes through and does not find a
        // video track, then we throw an exception here.
        if (videoTrack == null) {
            throw new IllegalActionException(
                    "The input media does not contain a video track.");
        }

        // Displays the video format in the debug window.
        if (_debugging) {
            _debug("Video format: " + videoTrack.getFormat());
        }

        // Instantiate and set the frame access codec to the data flow path.
        try {
            _cameraCodec = new PreAccessCodec();

            Codec[] codec = { _cameraCodec };
            videoTrack.setCodecChain(codec);
        } catch (UnsupportedPlugInException e) {
            throw new IllegalActionException(
                    "The process does not support codec plug ins.");
        }
View Full Code Here

      // #### 3b.2) handle multiple tracks
         TrackControl[] tracks=processor.getTrackControls();
         System.out.println("Number of tracks="+tracks.length);
         boolean enabled=false;  
         for (int i=0; i<tracks.length; i++)
         {  TrackControl track_control=tracks[i];
            Format format=track_control.getFormat();
            System.out.println("track#"+i+" format:"+format.toString());
            if (!enabled)
            {  if (format.toString().indexOf("Stereo")>0 || format.toString().indexOf("Mono")>0)
               {  if (type.equals("audio")) enabled=track_control.setFormat(new AudioFormat(AudioFormat.GSM_RTP))!=null;
                  else enabled=false;
               }
               else
               if (type.equals("video")) enabled=track_control.setFormat(new VideoFormat(VideoFormat.H263_RTP))!=null;
                  else enabled=false;
               }
               track_control.setEnabled(enabled);
               System.out.println("track#"+i+" enabled="+enabled);
            }
            else
            track_control.setEnabled(false);
               System.out.println("track#"+i+" disabled");
            }
         }
      }     
     
View Full Code Here

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

    // Query for the processor for supported formats.
    // Then set it on the processor.
    TrackControl tcs[] = p.getTrackControls();
    Format f[] = tcs[0].getSupportedFormats();
    if (f == null || f.length <= 0) {
      System.err.println("The mux does not support the input format: "
          + tcs[0].getFormat());
      return false;
View Full Code Here

        throw new IOException("JMFMovieEncoder error: Failed to configure processor");
      }

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

      TrackControl tcs[] = processor.getTrackControls();

      // Take the first supported format
      Format f[] = tcs[0].getSupportedFormats();

      //System.out.println("Supported formats:");
View Full Code Here

    if ( tc == null ) {
        System.out.println("Failed to get the track control from processor");
        return false;
    }

    TrackControl vtc = null;
   
    for ( int i =0; i < tc.length; i++ ) {
        if (tc[i].getFormat() instanceof VideoFormat ) {
      vtc = tc[i];
      break;
        }
       
    }

    if ( vtc == null ) {
        System.out.println("can't find video track");
        return false;
    }
   
    // Read video format
    VideoFormat f = (VideoFormat)vtc.getFormat();
    width = (int)f.getSize().getWidth();
    height = (int)f.getSize().getHeight();

    // create images
    bsGraphicsRenderer.setFrontBuffer(imageFactory.createBufferedImage((int)f.getSize().getWidth(), (int)f.getSize().getHeight(), BufferTypes.RGB_3Byte));
    bsGraphicsRenderer.setBackBuffer(imageFactory.createBufferedImage((int)f.getSize().getWidth(), (int)f.getSize().getHeight(), BufferTypes.RGB_3Byte));
   
    try {
        vtc.setRenderer(bsGraphicsRenderer);
    } catch ( Exception ex) {
        ex.printStackTrace();
        System.out.println("the processor does not support effect");
        return false;
    }
View Full Code Here

    // So I can use it as a player.
    processor.setContentDescriptor(null);

    // Obtain the track controls.
    TrackControl tc[] = processor.getTrackControls();

    if (tc == null) {
      System.err
          .println("Failed to obtain track controls from the processor.");
      return false;
    }

    // Search for the track control for the video track.
    TrackControl videoTrack = null;

    for (int i = 0; i < tc.length; i++) {
      if (tc[i].getFormat() instanceof VideoFormat) {
        videoTrack = tc[i];
        break;
      }
    }

    if (videoTrack == null) {
      System.err.println("The input media does not contain a video track.");
      return false;
    }

    System.err.println("Video format: " + videoTrack.getFormat());

    // Create the video codec chain.
    effectChain = createEffectChain();
   
    try {
      videoTrack.setCodecChain(effectChain);
    } catch (UnsupportedPlugInException e) {
      System.err.println("The process does not support effects.");
    }

    // Create the blob processing chain
View Full Code Here

TOP

Related Classes of javax.media.control.TrackControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.