com.amazonaws.services.elastictranscoder.AmazonElasticTranscoder Java Examples

The following examples show how to use com.amazonaws.services.elastictranscoder.AmazonElasticTranscoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Read.java    From openbd-core with GNU General Public License v3.0 6 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	String jobid	= getNamedStringParam(argStruct, "jobid", null );
	if ( jobid == null )
		throwException(_session, "Please specify a jobid" );

	try{
		ReadJobResult rjr = et.readJob( new ReadJobRequest().withId(jobid) );
		return new cfStringData( rjr.getJob().getStatus() );
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
	}

	return cfBooleanData.TRUE; 
}
 
Example #2
Source File: Cancel.java    From openbd-core with GNU General Public License v3.0 6 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	String jobid	= getNamedStringParam(argStruct, "jobid", null );
	if ( jobid == null )
		throwException(_session, "Please specify a jobid" );

	try{
		et.cancelJob( new CancelJobRequest().withId(jobid) );
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
	}

	return cfBooleanData.TRUE; 
}
 
Example #3
Source File: Read.java    From openbd-core with GNU General Public License v3.0 6 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	String pipelineid				= getNamedStringParam(argStruct, "pipelineid", null );
	if ( pipelineid == null )
		throwException(_session, "Please specify a pipelineid" );

	try{
		
		ReadPipelineResult rp = et.readPipeline( new ReadPipelineRequest().withId(pipelineid) );
		return getPipeline( rp.getPipeline() );
		
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
	}
	
	return cfBooleanData.TRUE; 
}
 
Example #4
Source File: Delete.java    From openbd-core with GNU General Public License v3.0 6 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	String pipelineid				= getNamedStringParam(argStruct, "pipelineid", null );
	if ( pipelineid == null )
		throwException(_session, "Please specify a pipelineid" );

	try{
		et.deletePipeline( new DeletePipelineRequest().withId(pipelineid) );
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
	}
	
	return cfBooleanData.TRUE; 
}
 
Example #5
Source File: UpdateStatus.java    From openbd-core with GNU General Public License v3.0 6 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	String pipelineid				= getNamedStringParam(argStruct, "pipelineid", null );
	if ( pipelineid == null )
		throwException(_session, "Please specify a pipelineid" );

	String status				= getNamedStringParam(argStruct, "status", null );
	if ( status == null )
		throwException(_session, "Please specify a status" );

	try{
		et.updatePipelineStatus( new UpdatePipelineStatusRequest().withId(pipelineid).withStatus(status) );
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
	}
	
	return cfBooleanData.TRUE; 
}
 
Example #6
Source File: ElasticTranscoderImpl.java    From studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public TranscoderJob startJob(String filename, InputStream content, TranscoderProfile profile) throws AwsException {
    try {
        AmazonS3 s3Client = getS3Client(profile);
        AmazonElasticTranscoder transcoderClient = getTranscoderClient(profile);
        Pipeline pipeline = getPipeline(profile.getPipelineId(), transcoderClient);
        String baseKey = FilenameUtils.removeExtension(filename) + "/" + UUID.randomUUID().toString();
        String inputKey = baseKey + "." + FilenameUtils.getExtension(filename);

        uploadInput(inputKey, filename, content, pipeline, s3Client);

        CreateJobResult jobResult = createJob(inputKey, baseKey, profile, transcoderClient);

        return createResult(baseKey, jobResult, pipeline);
    } catch (Exception e) {
        throw new AwsException("Error while attempting to start an AWS Elastic Transcoder job for file " + filename, e);
    }
}
 
Example #7
Source File: AmazonBase.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns back the necessary AmazonElasticTranscoder class for interacting with Elastic Transcoder
 * @param amazonKey
 * @return
 * @throws cfmRunTimeException
 */
public AmazonElasticTranscoder getAmazonElasticTranscoder( AmazonKey amazonKey ) throws cfmRunTimeException{
	BasicAWSCredentials awsCreds = new BasicAWSCredentials(amazonKey.getKey(), amazonKey.getSecret());
	AmazonElasticTranscoder et = new AmazonElasticTranscoderClient(awsCreds);
	et.setRegion( amazonKey.getAmazonRegion().toAWSRegion() );
	return et;
}
 
Example #8
Source File: ElasticTranscoderImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
protected Pipeline getPipeline(String pipelineId, AmazonElasticTranscoder client) {
    ReadPipelineRequest readPipelineRequest = new ReadPipelineRequest();
    readPipelineRequest.setId(pipelineId);

    ReadPipelineResult result = client.readPipeline(readPipelineRequest);

    return result.getPipeline();
}
 
Example #9
Source File: ElasticTranscoderImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
protected CreateJobResult createJob(String inputKey, String baseKey, TranscoderProfile profile,
                                    AmazonElasticTranscoder transcoderClient) {
    CreateJobRequest jobRequest = getCreateJobRequest(inputKey, baseKey, profile);
    CreateJobResult jobResult = transcoderClient.createJob(jobRequest);

    return jobResult;
}
 
Example #10
Source File: Create.java    From openbd-core with GNU General Public License v3.0 4 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	CreateJobRequest cjr	= new CreateJobRequest();

	cjr.setPipelineId( getNamedStringParam(argStruct, "pipelineid", null) );
	if ( cjr.getPipelineId() == null || cjr.getPipelineId().isEmpty() )
		throwException(_session, "please provide a valid pipelineid");

	cjr.setOutputKeyPrefix( getNamedStringParam(argStruct, "outputkeyprefix", null) );
	if ( cjr.getOutputKeyPrefix() != null && cjr.getOutputKeyPrefix().isEmpty() )
		throwException(_session, "please provide a valid outputkeyprefix");
	
	
	// Handle the input
	cfStructData	input	= getNamedStructParam( _session, argStruct, "input", null );
	if ( input == null )
		throwException(_session, "please provide a 'input'");
	
	JobInput jobinput	= new JobInput();
	
	if ( input.containsKey("aspectratio") )
		jobinput.setAspectRatio( input.getData("aspectratio").getString() );
	
	if ( input.containsKey("container") )
		jobinput.setContainer( input.getData("container").getString() );
	
	if ( input.containsKey("framerate") )
		jobinput.setFrameRate( input.getData("framerate").getString() );
	
	if ( input.containsKey("interlaced") )
		jobinput.setInterlaced( input.getData("interlaced").getString() );
	
	if ( input.containsKey("key") )
		jobinput.setKey( input.getData("key").getString() );
	
	if ( input.containsKey("resolution") )
		jobinput.setResolution( input.getData("resolution").getString() );
	
	if ( input.containsKey("encryption") )
		jobinput.setEncryption( getEncryption( (cfStructData)input.getData("encryption") ) );
		
	cjr.setInput(jobinput);
	
	
	// Set the output
	cfArrayData	outputArr	= getNamedArrayParam( _session, argStruct, "outputs", null );
	if ( outputArr == null )
		throwException(_session, "please provide 'outputs'");
	
	List<CreateJobOutput>	outputs	= new LinkedList();
	for ( int x=0; x < outputArr.size(); x++ )
		outputs.add( getCreateJobOutput( (cfStructData)outputArr.getData(x+1) ) );
	
	cjr.setOutputs(outputs);
	
	
	// Now after collection all that; create the actual pipeline
	try{
		CreateJobResult cpres = et.createJob(cjr);
		return new cfStringData( cpres.getJob().getId() ); 
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
		return cfBooleanData.TRUE;
	}
}
 
Example #11
Source File: Create.java    From openbd-core with GNU General Public License v3.0 4 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	CreatePipelineRequest cpr	= new CreatePipelineRequest();

	cpr.setName( getNamedStringParam(argStruct, "name", null) );
	if ( cpr.getName() == null || cpr.getName().isEmpty() || cpr.getName().length() > 40 )
		throwException(_session, "please provide a valid name (40chars or less)");
	
	cpr.setInputBucket( getNamedStringParam(argStruct, "inputbucket", null) );
	if ( cpr.getInputBucket() == null || cpr.getInputBucket().isEmpty() )
		throwException(_session, "please provide a valid inputbucket");
	
	cpr.setRole( getNamedStringParam(argStruct, "role", null) );
	if ( cpr.getRole() == null || cpr.getRole().isEmpty() )
		throwException(_session, "please provide a valid role");
	
	cpr.setAwsKmsKeyArn( getNamedStringParam(argStruct, "awskey", null) );
	if ( cpr.getAwsKmsKeyArn() == null || cpr.getAwsKmsKeyArn().isEmpty() )
		throwException(_session, "please provide a valid awskey");
	
	
	if ( getNamedStringParam(argStruct, "outputbucket", null) != null ){
		
		cpr.setOutputBucket( getNamedStringParam(argStruct, "outputbucket", null) );
		if ( cpr.getOutputBucket().isEmpty() )
			throwException(_session, "please provide a 'contentconfig' or a 'outputbucket'");

	}else{

		// Handle the ContentConfig
		cfStructData	cc	= getNamedStructParam( _session, argStruct, "contentconfig", null );
		if ( cc == null )
			throwException(_session, "please provide a 'contentconfig' or a 'outputbucket'");

		PipelineOutputConfig contentConfig	= new PipelineOutputConfig();
		
		contentConfig.setBucket( cc.getData("bucket").getString() );
		if ( contentConfig.getBucket() == null || contentConfig.getBucket().isEmpty() )
			throwException(_session, "please provide a 'contentconfig.bucket'");
		
		contentConfig.setStorageClass( cc.getData("storageclass").getString() );
		if ( contentConfig.getStorageClass() == null || contentConfig.getStorageClass().isEmpty() )
			throwException(_session, "please provide a 'contentconfig.storageclass'");
		
		Collection<Permission> permissions = getPermissions(_session, cc );
		if ( !permissions.isEmpty() )
			contentConfig.setPermissions( permissions );
		
		cpr.setContentConfig(contentConfig);

		
		// Handle the thumbnailconfig
		cc	= getNamedStructParam( _session, argStruct, "thumbnailconfig", null );
		if ( cc == null )
			throwException(_session, "please provide a 'thumbnailconfig' or a 'outputbucket'");

		contentConfig	= new PipelineOutputConfig();

		contentConfig.setBucket( cc.getData("bucket").getString() );
		if ( contentConfig.getBucket() == null || contentConfig.getBucket().isEmpty() )
			throwException(_session, "please provide a 'thumbnailconfig.bucket'");
		
		contentConfig.setStorageClass( cc.getData("storageclass").getString() );
		if ( contentConfig.getStorageClass() == null || contentConfig.getStorageClass().isEmpty() )
			throwException(_session, "please provide a 'thumbnailconfig.storageclass'");
		
		permissions = getPermissions(_session, cc );
		if ( !permissions.isEmpty() )
			contentConfig.setPermissions( permissions );

		cpr.setThumbnailConfig(contentConfig);
	}
	
	
	// Now after collection all that; create the actual pipeline
	try{
		CreatePipelineResult cpres = et.createPipeline(cpr);
		return new cfStringData( cpres.getPipeline().getId() ); 
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
		return cfBooleanData.TRUE;
	}
}
 
Example #12
Source File: ElasticTranscoderImpl.java    From studio with GNU General Public License v3.0 4 votes vote down vote up
protected AmazonElasticTranscoder getTranscoderClient(TranscoderProfile profile) {
    return AmazonElasticTranscoderClientBuilder.standard()
        .withCredentials(profile.getCredentialsProvider())
        .withRegion(profile.getRegion())
        .build();
}
 
Example #13
Source File: List.java    From openbd-core with GNU General Public License v3.0 3 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	try{
		cfArrayData	pipelines	= cfArrayData.createArray(1);

		ListPresetsRequest listObjectsRequest = new ListPresetsRequest();

		ListPresetsResult lpr;
		
		do {
			lpr = et.listPresets(listObjectsRequest);
		
			for (Preset preset: lpr.getPresets() )
				pipelines.addElement( getPreset(preset) );
		
			listObjectsRequest.setPageToken( lpr.getNextPageToken() );
		} while ( listObjectsRequest.getPageToken() != null );

		return pipelines;
		
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
	}
	
	return cfBooleanData.TRUE; 
}
 
Example #14
Source File: List.java    From openbd-core with GNU General Public License v3.0 3 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	String pipelineid				= getNamedStringParam(argStruct, "pipelineid", null );
	if ( pipelineid == null )
		throwException(_session, "Please specify a pipelineid" );

	
	try{
		cfArrayData	jobs	= cfArrayData.createArray(1);

		ListJobsByPipelineRequest listObjectsRequest = new ListJobsByPipelineRequest();

		ListJobsByPipelineResult lpr;
		
		do {
			lpr = et.listJobsByPipeline(listObjectsRequest);
		
			for (Job job : lpr.getJobs() )
				jobs.addElement( getJob(job) );
		
			listObjectsRequest.setPageToken( lpr.getNextPageToken() );
		} while ( listObjectsRequest.getPageToken() != null );

		return jobs;
		
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
	}
	
	return cfBooleanData.TRUE; 
}
 
Example #15
Source File: List.java    From openbd-core with GNU General Public License v3.0 3 votes vote down vote up
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{
	AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
	AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

	try{
		cfArrayData	pipelines	= cfArrayData.createArray(1);

		ListPipelinesRequest listObjectsRequest = new ListPipelinesRequest();

		ListPipelinesResult lpr;
		
		do {
			lpr = et.listPipelines(listObjectsRequest);
		
			for (Pipeline pipeline : lpr.getPipelines())
				pipelines.addElement( getPipeline(pipeline) );
		
			listObjectsRequest.setPageToken( lpr.getNextPageToken() );
		} while ( listObjectsRequest.getPageToken() != null );

		return pipelines;
		
	}catch(Exception e){
		throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() );
	}
	
	return cfBooleanData.TRUE; 
}