use of com.qcloud.cos.model.ciModel.template.MediaSnapshotObject in project cos-java-sdk-v5 by tencentyun.
the class RequestXmlFactory method convertToXmlByteArray.
/**
* Converts the MediaTemplateRequest to an XML fragment that can be sent to the TemplateObject of COS MediaTemplate
*
* @param request The container which provides options for restoring an object
* @return A byte array containing the data
* @throws CosClientException
*/
public static byte[] convertToXmlByteArray(MediaTemplateRequest request) {
XmlWriter xml = new XmlWriter();
String tag = request.getTag();
xml.start("Request");
xml.start("Tag").value(tag).end();
xml.start("Name").value(request.getName()).end();
if ("Animation".equalsIgnoreCase(tag)) {
xml.start("Container");
xml.start("Format").value(request.getContainer().getFormat()).end();
xml.end();
addVideo(xml, request);
if (CheckObjectUtils.objIsNotValid(request.getTimeInterval())) {
xml.start("TimeInterval");
xml.start("Duration").value(request.getTimeInterval().getDuration()).end();
xml.start("Start").value(request.getTimeInterval().getStart()).end();
xml.end();
}
} else if ("Snapshot".equalsIgnoreCase(tag)) {
if (CheckObjectUtils.objIsNotValid(request.getSnapshot())) {
xml.start("Snapshot");
MediaSnapshotObject snapshot = request.getSnapshot();
addIfNotNull(xml, "Mode", snapshot.getMode());
addIfNotNull(xml, "Count", snapshot.getCount());
addIfNotNull(xml, "Fps", snapshot.getFps());
addIfNotNull(xml, "Height", snapshot.getHeight());
addIfNotNull(xml, "Start", snapshot.getStart());
addIfNotNull(xml, "TimeInterval", snapshot.getTimeInterval());
addIfNotNull(xml, "Width", snapshot.getWidth());
xml.end();
}
} else if ("Watermark".equalsIgnoreCase(tag)) {
xml.start("Watermark");
addIfNotNull(xml, "Type", request.getWatermark().getType());
addIfNotNull(xml, "Dx", request.getWatermark().getDx());
addIfNotNull(xml, "Dy", request.getWatermark().getDy());
addIfNotNull(xml, "EndTime", request.getWatermark().getEndTime());
addIfNotNull(xml, "LocMode", request.getWatermark().getLocMode());
addIfNotNull(xml, "Pos", request.getWatermark().getPos());
addIfNotNull(xml, "StartTime", request.getWatermark().getStartTime());
if ("Text".equalsIgnoreCase(request.getWatermark().getType())) {
xml.start("Text");
MediaWaterMarkText text = request.getWatermark().getText();
addIfNotNull(xml, "FontColor", text.getFontColor());
addIfNotNull(xml, "FontSize", text.getFontSize());
addIfNotNull(xml, "FontType", text.getFontType());
addIfNotNull(xml, "Text", text.getText());
addIfNotNull(xml, "Transparency", text.getTransparency());
xml.end();
} else if ("Image".equalsIgnoreCase(request.getWatermark().getType())) {
xml.start("Image");
MediaWaterMarkImage image = request.getWatermark().getImage();
addIfNotNull(xml, "Height", image.getHeight());
addIfNotNull(xml, "Mode", image.getMode());
addIfNotNull(xml, "Url", image.getUrl());
addIfNotNull(xml, "Transparency", image.getTransparency());
addIfNotNull(xml, "Width", image.getWidth());
xml.end();
}
xml.end();
} else if ("Transcode".equalsIgnoreCase(tag)) {
xml.start("Container");
xml.start("Format").value(request.getContainer().getFormat()).end();
xml.end();
xml.start("TimeInterval");
xml.start("Duration").value(request.getTimeInterval().getDuration()).end();
xml.start("Start").value(request.getTimeInterval().getStart()).end();
xml.end();
addAudio(xml, request.getAudio());
xml.start("TransConfig");
addIfNotNull(xml, "AdjDarMethod", request.getTransConfig().getAdjDarMethod());
addIfNotNull(xml, "AudioBitrateAdjMethod", request.getTransConfig().getAudioBitrateAdjMethod());
addIfNotNull(xml, "IsCheckAudioBitrate", request.getTransConfig().getIsCheckAudioBitrate());
addIfNotNull(xml, "IsCheckReso", request.getTransConfig().getIsCheckReso());
addIfNotNull(xml, "IsCheckVideoBitrate", request.getTransConfig().getIsCheckVideoBitrate());
addIfNotNull(xml, "ResoAdjMethod", request.getTransConfig().getResoAdjMethod());
addIfNotNull(xml, "TransMode", request.getTransConfig().getTransMode());
addIfNotNull(xml, "VideoBitrateAdjMethod", request.getTransConfig().getVideoBitrateAdjMethod());
xml.end();
addVideo(xml, request);
}
xml.end();
return xml.getBytes();
}
Aggregations