Skip to content

Commit cc5b0ee

Browse files
committed
Merge pull request #14 from aleksey-korolev/master
Add field pass_through to ZencoderJob
2 parents 740d967 + c49ac9b commit cc5b0ee

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/main/java/de/bitzeche/video/transcoding/zencoder/job/ZencoderJob.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public class ZencoderJob {
4949

5050
private List<ZencoderNotification> notifications = new ArrayList<ZencoderNotification>();
5151

52+
/**
53+
* According to <a href="zencoder API documentation">https://app.zencoder.com/docs/api/encoding</a> pass_through is
54+
* "Optional information to store alongside this job".<br/>
55+
* When pass_through field is provided during job submission it becomes available in job notification
56+
* callback from the service.
57+
*/
58+
private String passThrough;
59+
5260

5361
public ZencoderJob(String inputPath) {
5462
this.inputPath = inputPath;
@@ -92,6 +100,12 @@ public Document createXML() throws ParserConfigurationException {
92100
download_connections.setTextContent("" + this.downloadConnections);
93101
root.appendChild(download_connections);
94102

103+
if (getPassThrough() != null) {
104+
Node passThroughNode = document.createElement("pass_through");
105+
passThroughNode.setTextContent(this.getPassThrough());
106+
root.appendChild(passThroughNode);
107+
}
108+
95109
Node test = document.createElement("test");
96110
test.setTextContent((this.isTest ? "1" : "0"));
97111
root.appendChild(test);
@@ -163,7 +177,11 @@ public int getDownloadConnections() {
163177
return downloadConnections;
164178
}
165179

166-
public boolean isTest() {
180+
public String getPassThrough() {
181+
return passThrough;
182+
}
183+
184+
public boolean isTest() {
167185
return isTest;
168186
}
169187

@@ -198,4 +216,8 @@ public void addNotification(ZencoderNotification item) {
198216
public void deleteNotification(ZencoderNotification item) {
199217
this.notifications.remove(item);
200218
}
219+
220+
public void setPassThrough(String passThrough) {
221+
this.passThrough = passThrough;
222+
}
201223
}

src/test/java/de/bitzeche/video/transcoding/zencoder/test/ZencoderJobTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,18 @@ public void testWithOptions() throws ParserConfigurationException {
4545
job.setTest(true);
4646
job.setPrivate(true);
4747
job.setZencoderRegion(ZencoderRegion.ASIA);
48-
48+
job.setPassThrough("user_id:100");
49+
4950
String doc = StringUtil.stripSpacesAndLineBreaksFrom(job.toString());
50-
String expected = ("<?xmlversion=\"1.0\"encoding=\"UTF-8\"?><api-request><input>http://testpath/</input><region>asia</region><download_connections>10</download_connections><test>1</test><private>1</private></api-request>");
51+
String expected = ("<?xmlversion=\"1.0\"encoding=\"UTF-8\"?>" +
52+
"<api-request>" +
53+
"<input>http://testpath/</input>" +
54+
"<region>asia</region>" +
55+
"<download_connections>10</download_connections>" +
56+
"<pass_through>user_id:100</pass_through>" +
57+
"<test>1</test>" +
58+
"<private>1</private>" +
59+
"</api-request>");
5160
Assert.assertEquals(doc, expected);
5261
}
5362

0 commit comments

Comments
 (0)