use of com.mizhousoft.cloudsdk.vod.MediaMeta in project cloud-sdk by mizhousoft.
the class QCloudVODServiceImpl method buildMediaMeta.
private MediaMeta buildMediaMeta(String fileId, MediaBasicInfo basicInfo, MediaMetaData metaData, MediaTranscodeInfo transcodeInfo) {
MediaMeta midiaMeta = new MediaMeta();
midiaMeta.setFileId(fileId);
if (null != basicInfo) {
midiaMeta.setName(basicInfo.getName());
midiaMeta.setType(basicInfo.getType());
midiaMeta.setMediaUrl(basicInfo.getMediaUrl());
midiaMeta.setCoverUrl(basicInfo.getCoverUrl());
}
if (null != metaData) {
midiaMeta.setDuration(metaData.getDuration().intValue());
midiaMeta.setMediaFileSize(metaData.getSize());
MediaVideoStreamItem[] videoStreams = metaData.getVideoStreamSet();
if (!ArrayUtils.isEmpty(videoStreams)) {
MediaVideoStreamItem videoStream = videoStreams[0];
String codec = videoStream.getCodec();
midiaMeta.setCodec(codec);
}
}
if (null != transcodeInfo) {
MediaTranscodeItem[] list = ArrayUtils.nullToEmpty(transcodeInfo.getTranscodeSet(), MediaTranscodeItem[].class);
for (int i = list.length - 1; i >= 0; --i) {
MediaTranscodeItem item = list[i];
MediaVideoStreamItem[] videoStreams = item.getVideoStreamSet();
if (ArrayUtils.isEmpty(videoStreams)) {
continue;
}
MediaVideoStreamItem videoStream = videoStreams[0];
String codec = videoStream.getCodec();
if (MediaCodecEnum.H264.isSelf(codec)) {
midiaMeta.setCodec(codec);
midiaMeta.setDuration(item.getDuration().intValue());
midiaMeta.setMediaFileSize(item.getSize());
midiaMeta.setMediaUrl(item.getUrl());
break;
}
}
}
return midiaMeta;
}
use of com.mizhousoft.cloudsdk.vod.MediaMeta in project cloud-sdk by mizhousoft.
the class QCloudVODServiceImpl method convertToEvent.
private VodEvent convertToEvent(EventContent content) {
String eventId = content.getEventHandle();
String eventType = content.getEventType();
if ("NewFileUpload".equals(eventType)) {
FileUploadTask uploadTask = content.getFileUploadEvent();
MediaMeta mediaMeta = buildMediaMeta(uploadTask.getFileId(), uploadTask.getMediaBasicInfo(), uploadTask.getMetaData(), null);
return new VodNewFileUploadEvent(eventId, mediaMeta);
} else if ("ProcedureStateChanged".equals(eventType)) {
ProcedureTask precTask = content.getProcedureStateChangeEvent();
boolean completed = "FINISH".equals(precTask.getStatus());
return new VodStateChangedEvent(eventId, precTask.getFileId(), completed);
} else if ("FileDeleted".equals(eventType)) {
FileDeleteTask deleteTask = content.getFileDeleteEvent();
return new VodFileDeletedEvent(eventId, deleteTask.getFileIdSet());
} else {
return new VodEvent(eventId);
}
}
use of com.mizhousoft.cloudsdk.vod.MediaMeta in project cloud-sdk by mizhousoft.
the class QCloudVODServiceImpl method getVideoMeta.
/**
* {@inheritDoc}
*/
@Override
public MediaMeta getVideoMeta(String fileId) throws CloudSDKException {
try {
String[] fileIds = { fileId };
DescribeMediaInfosRequest req = new DescribeMediaInfosRequest();
req.setFileIds(fileIds);
DescribeMediaInfosResponse resp = vodClient.DescribeMediaInfos(req);
MediaInfo[] mediaInfos = resp.getMediaInfoSet();
if (null != mediaInfos && 1 == mediaInfos.length) {
MediaInfo mediaInfo = mediaInfos[0];
MediaMeta meta = buildMediaMeta(fileId, mediaInfo.getBasicInfo(), mediaInfo.getMetaData(), mediaInfo.getTranscodeInfo());
return meta;
} else {
return null;
}
} catch (TencentCloudSDKException e) {
throw new CloudSDKException(e.getErrorCode(), e.getMessage(), e);
}
}
use of com.mizhousoft.cloudsdk.vod.MediaMeta in project cloud-sdk by mizhousoft.
the class TestQCloudVODServiceImpl method getVideoMeta.
@Test
public void getVideoMeta() {
try {
MediaMeta mediaMeta = vodService.getVideoMeta("5285890786997530566");
Assert.assertNotNull(mediaMeta);
} catch (CloudSDKException e) {
Assert.fail(e.getMessage());
}
}
Aggregations