use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.
the class JobAdapter method unmarshal.
public Job unmarshal(JaxbSafeJob jaxbSafeJob) throws Exception {
if (jaxbSafeJob == null) {
return null;
}
Job job = new Job();
try {
job.setJobTrigger(jaxbSafeJob.jobTrigger);
job.setJobParams(toProperMap(jaxbSafeJob.jobParams));
job.setLastRun(jaxbSafeJob.lastRun);
job.setNextRun(jaxbSafeJob.nextRun);
job.setSchedulableClass(jaxbSafeJob.schedulableClass);
job.setJobId(jaxbSafeJob.jobId);
job.setUserName(jaxbSafeJob.userName);
job.setJobName(jaxbSafeJob.jobName);
job.setState(jaxbSafeJob.state);
} catch (Throwable t) {
// no message bundle since this is a development error case
// $NON-NLS-1$
logger.error("Error unmarshalling job", t);
return null;
}
return job;
}
use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.
the class QuartzSchedulerTest method testSetJobNextRunToTheFuture.
@Test
public void testSetJobNextRunToTheFuture() {
Trigger trigger = Mockito.mock(Trigger.class);
Job job = new Job();
QuartzScheduler quartzScheduler = new QuartzScheduler();
long nowDate = new Date().getTime();
long futureDate = nowDate + 1000000000;
Mockito.when(trigger.getNextFireTime()).thenReturn(new Date(futureDate));
Mockito.when(trigger.getFireTimeAfter(any())).thenReturn(new Date(nowDate));
quartzScheduler.setJobNextRun(job, trigger);
assertEquals(new Date(futureDate), job.getNextRun());
}
use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.
the class QuartzSchedulerTest method testSetJobNextRunToThePast.
@Test
public void testSetJobNextRunToThePast() {
Trigger trigger = Mockito.mock(Trigger.class);
Job job = new Job();
QuartzScheduler quartzScheduler = new QuartzScheduler();
long nowDate = new Date().getTime();
long pastDate = nowDate - 1000000000;
Mockito.when(trigger.getNextFireTime()).thenReturn(new Date(pastDate));
Mockito.when(trigger.getFireTimeAfter(any())).thenReturn(new Date(nowDate));
quartzScheduler.setJobNextRun(job, trigger);
assertEquals(new Date(nowDate), job.getNextRun());
}
use of com.google.cloud.video.transcoder.v1.Job in project pentaho-platform by pentaho.
the class DefaultSchedulerServiceTest method mockJob.
private Job mockJob(String userName, String jobName) {
Job job = mock(Job.class);
when(job.getUserName()).thenReturn(userName);
when(job.getJobName()).thenReturn(jobName);
return job;
}
use of com.google.cloud.video.transcoder.v1.Job in project java-docs-samples by GoogleCloudPlatform.
the class CreateJobWithSetNumberImagesSpritesheet method createJobWithSetNumberImagesSpritesheet.
// Creates a job from an ad-hoc configuration and generates two spritesheets from the input video.
// Each spritesheet contains a set number of images.
public static void createJobWithSetNumberImagesSpritesheet(String projectId, String location, String inputUri, String outputUri) throws IOException {
// once, and can be reused for multiple requests.
try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
VideoStream videoStream0 = VideoStream.newBuilder().setH264(VideoStream.H264CodecSettings.newBuilder().setBitrateBps(550000).setFrameRate(60).setHeightPixels(360).setWidthPixels(640)).build();
AudioStream audioStream0 = AudioStream.newBuilder().setCodec("aac").setBitrateBps(64000).build();
// Generates a 10x10 spritesheet of small images from the input video. To preserve the source
// aspect ratio, you should set the spriteWidthPixels field or the spriteHeightPixels
// field, but not both.
SpriteSheet smallSpriteSheet = SpriteSheet.newBuilder().setFilePrefix(smallSpritesheetFilePrefix).setSpriteHeightPixels(32).setSpriteWidthPixels(64).setColumnCount(10).setRowCount(10).setTotalCount(100).build();
// Generates a 10x10 spritesheet of larger images from the input video.
SpriteSheet largeSpriteSheet = SpriteSheet.newBuilder().setFilePrefix(largeSpritesheetFilePrefix).setSpriteHeightPixels(72).setSpriteWidthPixels(128).setColumnCount(10).setRowCount(10).setTotalCount(100).build();
JobConfig config = JobConfig.newBuilder().addInputs(Input.newBuilder().setKey("input0").setUri(inputUri)).setOutput(Output.newBuilder().setUri(outputUri)).addElementaryStreams(ElementaryStream.newBuilder().setKey("video_stream0").setVideoStream(videoStream0)).addElementaryStreams(ElementaryStream.newBuilder().setKey("audio_stream0").setAudioStream(audioStream0)).addMuxStreams(MuxStream.newBuilder().setKey("sd").setContainer("mp4").addElementaryStreams("video_stream0").addElementaryStreams("audio_stream0").build()).addSpriteSheets(// Add the spritesheet config to the job config
smallSpriteSheet).addSpriteSheets(// Add the spritesheet config to the job config
largeSpriteSheet).build();
var createJobRequest = CreateJobRequest.newBuilder().setJob(Job.newBuilder().setInputUri(inputUri).setOutputUri(outputUri).setConfig(config).build()).setParent(LocationName.of(projectId, location).toString()).build();
// Send the job creation request and process the response.
Job job = transcoderServiceClient.createJob(createJobRequest);
System.out.println("Job: " + job.getName());
}
}
Aggregations