Package ca.carleton.gcrc.olkit.multimedia.utils.MimeUtils

Examples of ca.carleton.gcrc.olkit.multimedia.utils.MimeUtils.MultimediaClass


    MultimediaConversionRequest request = new MultimediaConversionRequest();
    request.setInFile( originalFile );
    request.setThumbnailRequested(true);
    request.setProgress( new UploadProgressAdaptor() );
   
    MultimediaClass mmClass = MimeUtils.getMultimediaClassFromMimeType(mimeType);
    if( MultimediaClass.VIDEO == mmClass ) {
      // For video file, convert to appropriate file type
      mmConverter.convertVideo(request);

    } else if( MultimediaClass.AUDIO == mmClass ) {
View Full Code Here


      SystemFile sf = SystemFile.getSystemFile(file);
      String mimeType = sf.getMimeType();
      String mimeEncoding = sf.getMimeEncoding();
 
      // Is it a known MIME type?
      MultimediaClass aClass = MimeUtils.getMultimediaClassFromMimeType(sf.getMimeType());
      if( MultimediaClass.AUDIO == aClass
       || MultimediaClass.VIDEO == aClass
       || MultimediaClass.IMAGE == aClass
       ) {
        String fileClass = aClass.getValue();
       
        result.setMimeType(mimeType);
        result.setMimeEncoding(mimeEncoding);
        result.setFileClass(fileClass);
        result.setFileConvertable(true);
View Full Code Here

    MultimediaConversionRequest request = new MultimediaConversionRequest();
    request.setInFile( originalFile );
    request.setThumbnailRequested(true);
    request.setProgress( new UploadProgressAdaptor() );
   
    MultimediaClass mmClass = MimeUtils.getMultimediaClassFromMimeType(mimeType);
    if( MultimediaClass.VIDEO == mmClass ) {
      // For video file, convert to appropriate file type
      mmConverter.convertVideo(request);

    } else if( MultimediaClass.AUDIO == mmClass ) {
View Full Code Here

    MultimediaConversionRequest request = new MultimediaConversionRequest();
    request.setInFile( inFile );
    request.setThumbnailFile(outFile);
    request.setThumbnailRequested(true);
   
    MultimediaClass mmClass = MimeUtils.getMultimediaClassFromMimeType(mimeType);
    if( MultimediaClass.IMAGE == mmClass ) {
      // For image file, convert to appropriate file type
      mmConverter.createImageThumbnail(request);
     
    } else {
View Full Code Here

      SystemFile sf = SystemFile.getSystemFile(file);
      mimeType = sf.getMimeType();
      mimeEncoding = sf.getMimeEncoding();

      // Is it a known MIME type?
      MultimediaClass aClass = MimeUtils.getMultimediaClassFromMimeType(sf.getMimeType());
      if( MultimediaClass.AUDIO == aClass
       || MultimediaClass.VIDEO == aClass
       || MultimediaClass.IMAGE == aClass
       ) {
        fileClass = aClass.getValue();
      }
    }
   
    doc.put(UploadConstants.UPLOAD_KEY, UploadConstants.UPLOAD_VALUE_ANALYZED);
    originalObj.put(UploadConstants.SIZE_KEY, fileSize);
View Full Code Here

    MultimediaConversionRequest request = new MultimediaConversionRequest();
    request.setInFile( file );
    request.setThumbnailRequested(true);
    request.setProgress( new MultimediaProgressAdaptor() );
   
    MultimediaClass mmClass = MimeUtils.getMultimediaClassFromMimeType(mimeType);
    if( MultimediaClass.VIDEO == mmClass ) {
      // For video file, convert to appropriate file type
      mmConverter.convertVideo(request);

    } else if( MultimediaClass.AUDIO == mmClass ) {
      // For audio file, convert to appropriate file type
      mmConverter.convertAudio(request);
     
    } else if( MultimediaClass.IMAGE == mmClass ) {
      // For image file, convert to appropriate file type
      mmConverter.convertImage(request);
     
    } else {
      // No conversion required. Go directly to waiting for approval
      doc.put(UploadConstants.UPLOAD_KEY, UploadConstants.UPLOAD_VALUE_WAITING_FOR_APPROVAL);
      dd.getDatabase().updateDocument(doc);
      sendContributionApprovalRequest(docId, doc);
      return;
    }
   
    // Report original size
    if( request.getInHeight() != 0 && request.getInWidth() != 0 ) {
      originalObj.put("height", request.getInHeight());
      originalObj.put("width", request.getInWidth());
    }
   

    // Report converted object
    {
      File convertedFile = request.getOutFile();
      SystemFile convertedSf = SystemFile.getSystemFile(convertedFile);

      JSONObject convertedObj = new JSONObject();
      convertedObj.put("conversionPerformed", request.isConversionPerformed());
      convertedObj.put("media", convertedFile.getName());
      convertedObj.put(UploadConstants.SIZE_KEY, convertedFile.length());
      convertedObj.put(UploadConstants.MIME_KEY, convertedSf.getMimeType());
      convertedObj.put(UploadConstants.ENCODING_KEY, convertedSf.getMimeEncoding());

      if( request.getOutHeight() != 0 && request.getOutWidth() != 0 ) {
        convertedObj.put("height", request.getOutHeight());
        convertedObj.put("width", request.getOutWidth());
      }
     
      doc.put("converted",convertedObj);
    }

    // Report thumbnail object
    if( request.isThumbnailCreated() ) {
      File thumbFile = request.getThumbnailFile();
      SystemFile thumbSf = SystemFile.getSystemFile(thumbFile);

      // Report converted object
      JSONObject thumbObj = new JSONObject();
      thumbObj.put("media", thumbFile.getName());
      thumbObj.put(UploadConstants.SIZE_KEY, thumbFile.length());
      thumbObj.put(UploadConstants.MIME_KEY, thumbSf.getMimeType());
      thumbObj.put(UploadConstants.ENCODING_KEY, thumbSf.getMimeEncoding());

      if( request.getThumbnailHeight() != 0 && request.getThumbnailWidth() != 0 ) {
        thumbObj.put("height", request.getThumbnailHeight());
        thumbObj.put("width", request.getThumbnailWidth());
      }

      doc.put("thumbnail",thumbObj);
    }
   
    // Mark end of this phase
    doc.put(UploadConstants.UPLOAD_KEY, UploadConstants.UPLOAD_VALUE_WAITING_FOR_APPROVAL);
    doc.put(UploadConstants.MIME_CLASS_KEY, mmClass.getValue());

    dd.getDatabase().updateDocument(doc);
   
    // Notify that upload is available
    sendContributionApprovalRequest(docId, doc);
View Full Code Here

    originalObj.put(UploadConstants.MIME_KEY, sf.getMimeType());
    originalObj.put(UploadConstants.ENCODING_KEY, sf.getMimeEncoding());
   
    // Is it a known MIME type?
    {
      MultimediaClass aClass = MimeUtils.getMultimediaClassFromMimeType(sf.getMimeType());
      if( MultimediaClass.AUDIO == aClass
       || MultimediaClass.VIDEO == aClass
       || MultimediaClass.IMAGE == aClass
       ) {
        doc.put(UploadConstants.MIME_CLASS_KEY, aClass.getValue());
      }
    }
   
    dd.getDatabase().updateDocument(doc);
  }
View Full Code Here

    MultimediaConversionRequest request = new MultimediaConversionRequest();
    request.setInFile( file );
    request.setThumbnailRequested(true);
    request.setProgress( new MultimediaProgressAdaptor() );
   
    MultimediaClass mmClass = MimeUtils.getMultimediaClassFromMimeType(mimeType);
    if( MultimediaClass.VIDEO == mmClass ) {
      // For video file, convert to appropriate file type
      mmConverter.convertVideo(request);

    } else if( MultimediaClass.AUDIO == mmClass ) {
      // For audio file, convert to appropriate file type
      mmConverter.convertAudio(request);
     
    } else if( MultimediaClass.IMAGE == mmClass ) {
      // For image file, convert to appropriate file type
      mmConverter.convertImage(request);
     
    } else {
      throw new Exception("Unable to handle MIME type: "+mimeType);
    }
   
    // Report original size
    if( request.getInHeight() != 0 && request.getInWidth() != 0 ) {
      originalObj.put("height", request.getInHeight());
      originalObj.put("width", request.getInWidth());
    }
   

    // Report converted object
    {
      File convertedFile = request.getOutFile();
      SystemFile convertedSf = SystemFile.getSystemFile(convertedFile);

      JSONObject convertedObj = new JSONObject();
      convertedObj.put("conversionPerformed", request.isConversionPerformed());
      convertedObj.put("media", convertedFile.getName());
      convertedObj.put(UploadConstants.SIZE_KEY, convertedFile.length());
      convertedObj.put(UploadConstants.MIME_KEY, convertedSf.getMimeType());
      convertedObj.put(UploadConstants.ENCODING_KEY, convertedSf.getMimeEncoding());

      if( request.getOutHeight() != 0 && request.getOutWidth() != 0 ) {
        convertedObj.put("height", request.getOutHeight());
        convertedObj.put("width", request.getOutWidth());
      }
     
      doc.put("converted",convertedObj);
    }

    // Report thumbnail object
    if( request.isThumbnailCreated() ) {
      File thumbFile = request.getThumbnailFile();
      SystemFile thumbSf = SystemFile.getSystemFile(thumbFile);

      // Report converted object
      JSONObject thumbObj = new JSONObject();
      thumbObj.put("media", thumbFile.getName());
      thumbObj.put(UploadConstants.SIZE_KEY, thumbFile.length());
      thumbObj.put(UploadConstants.MIME_KEY, thumbSf.getMimeType());
      thumbObj.put(UploadConstants.ENCODING_KEY, thumbSf.getMimeEncoding());

      if( request.getThumbnailHeight() != 0 && request.getThumbnailWidth() != 0 ) {
        thumbObj.put("height", request.getThumbnailHeight());
        thumbObj.put("width", request.getThumbnailWidth());
      }

      doc.put("thumbnail",thumbObj);
    }
   
    // Mark end of this phase
    doc.put(UploadConstants.UPLOAD_KEY, UploadConstants.UPLOAD_VALUE_CONVERTED);
    doc.put(UploadConstants.MIME_CLASS_KEY, mmClass.getValue());

    dd.getDatabase().updateDocument(doc);
  }
View Full Code Here

    originalObj.put(UploadConstants.MIME_KEY, sf.getMimeType());
    originalObj.put(UploadConstants.ENCODING_KEY, sf.getMimeEncoding());
   
    // Is it a known MIME type?
    {
      MultimediaClass aClass = MimeUtils.getMultimediaClassFromMimeType(sf.getMimeType());
      if( MultimediaClass.AUDIO == aClass
       || MultimediaClass.VIDEO == aClass
       || MultimediaClass.IMAGE == aClass
       ) {
        doc.put(UploadConstants.MIME_CLASS_KEY, aClass.getValue());
      }
    }
   
    dd.getDatabase().updateDocument(doc);
  }
View Full Code Here

    MultimediaConversionRequest request = new MultimediaConversionRequest();
    request.setInFile( file );
    request.setThumbnailRequested(true);
    request.setProgress( new MultimediaProgressAdaptor() );
   
    MultimediaClass mmClass = MimeUtils.getMultimediaClassFromMimeType(mimeType);
    if( MultimediaClass.VIDEO == mmClass ) {
      // For video file, convert to appropriate file type
      mmConverter.convertVideo(request);

    } else if( MultimediaClass.AUDIO == mmClass ) {
      // For audio file, convert to appropriate file type
      mmConverter.convertAudio(request);
     
    } else if( MultimediaClass.IMAGE == mmClass ) {
      // For image file, convert to appropriate file type
      mmConverter.convertImage(request);
     
    } else {
      // No conversion required. Go directly to waiting for approval
      doc.put(UploadConstants.UPLOAD_KEY, UploadConstants.UPLOAD_VALUE_WAITING_FOR_APPROVAL);
      dd.getDatabase().updateDocument(doc);
      sendContributionApprovalRequest(docId, doc);
      return;
    }
   
    // Report original size
    if( request.getInHeight() != 0 && request.getInWidth() != 0 ) {
      originalObj.put("height", request.getInHeight());
      originalObj.put("width", request.getInWidth());
    }
   

    // Report converted object
    {
      File convertedFile = request.getOutFile();
      SystemFile convertedSf = SystemFile.getSystemFile(convertedFile);

      JSONObject convertedObj = new JSONObject();
      convertedObj.put("conversionPerformed", request.isConversionPerformed());
      convertedObj.put("media", convertedFile.getName());
      convertedObj.put(UploadConstants.SIZE_KEY, convertedFile.length());
      convertedObj.put(UploadConstants.MIME_KEY, convertedSf.getMimeType());
      convertedObj.put(UploadConstants.ENCODING_KEY, convertedSf.getMimeEncoding());

      if( request.getOutHeight() != 0 && request.getOutWidth() != 0 ) {
        convertedObj.put("height", request.getOutHeight());
        convertedObj.put("width", request.getOutWidth());
      }
     
      doc.put("converted",convertedObj);
    }

    // Report thumbnail object
    if( request.isThumbnailCreated() ) {
      File thumbFile = request.getThumbnailFile();
      SystemFile thumbSf = SystemFile.getSystemFile(thumbFile);

      // Report converted object
      JSONObject thumbObj = new JSONObject();
      thumbObj.put("media", thumbFile.getName());
      thumbObj.put(UploadConstants.SIZE_KEY, thumbFile.length());
      thumbObj.put(UploadConstants.MIME_KEY, thumbSf.getMimeType());
      thumbObj.put(UploadConstants.ENCODING_KEY, thumbSf.getMimeEncoding());

      if( request.getThumbnailHeight() != 0 && request.getThumbnailWidth() != 0 ) {
        thumbObj.put("height", request.getThumbnailHeight());
        thumbObj.put("width", request.getThumbnailWidth());
      }

      doc.put("thumbnail",thumbObj);
    }
   
    // Mark end of this phase
    doc.put(UploadConstants.UPLOAD_KEY, UploadConstants.UPLOAD_VALUE_WAITING_FOR_APPROVAL);
    doc.put(UploadConstants.MIME_CLASS_KEY, mmClass.getValue());

    dd.getDatabase().updateDocument(doc);
   
    // Notify that upload is available
    sendContributionApprovalRequest(docId, doc);
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.olkit.multimedia.utils.MimeUtils.MultimediaClass

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.