@@ -25,12 +25,17 @@ discard block |
||
25 | 25 | public function checkOptionParameters() |
26 | 26 | { |
27 | 27 | list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
28 | - if (!$valid) |
|
29 | - return array($valid, $msg, null); |
|
30 | - if (empty($this->encodeTemplate)) |
|
31 | - return array(false, "encodeTemplate is empty.", null); // 判断是否设置输入输出文件,或者转码模板 |
|
32 | - if (($this->usePreset != 0 && $this->usePreset != 1) || ($this->force != 0 && $this->force != 1)) |
|
33 | - return array(false, "parameters 'usePreset' or 'force' is invalid.", null); // 判断usePreset和force参数是否为0或1 |
|
28 | + if (!$valid) { |
|
29 | + return array($valid, $msg, null); |
|
30 | + } |
|
31 | + if (empty($this->encodeTemplate)) { |
|
32 | + return array(false, "encodeTemplate is empty.", null); |
|
33 | + } |
|
34 | + // 判断是否设置输入输出文件,或者转码模板 |
|
35 | + if (($this->usePreset != 0 && $this->usePreset != 1) || ($this->force != 0 && $this->force != 1)) { |
|
36 | + return array(false, "parameters 'usePreset' or 'force' is invalid.", null); |
|
37 | + } |
|
38 | + // 判断usePreset和force参数是否为0或1 |
|
34 | 39 | return $this->getOptionsHttpBody(); //返回http请求体 |
35 | 40 | } |
36 | 41 | /**构建多媒体转码所需的http请求体*/ |
@@ -43,16 +48,21 @@ discard block |
||
43 | 48 | $httpBody .= '&usePreset=' . $this->usePreset; |
44 | 49 | $httpBody .= '&force=' . $this->force; |
45 | 50 | // 可选的参数 |
46 | - if (isset($this->watermark)) |
|
47 | - $httpBody .= '&watermark=' . $this->watermark->buildResourceId(); |
|
48 | - if (isset($this->watermarkTemplate)) |
|
49 | - $httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate); |
|
50 | - if (isset($this->notifyUrl)) |
|
51 | - $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
52 | - if (isset($this->seek)) |
|
53 | - $httpBody .= '&seek=' . $this->seek; |
|
54 | - if (isset($this->duration)) |
|
55 | - $httpBody .= '&duration=' . $this->duration; |
|
51 | + if (isset($this->watermark)) { |
|
52 | + $httpBody .= '&watermark=' . $this->watermark->buildResourceId(); |
|
53 | + } |
|
54 | + if (isset($this->watermarkTemplate)) { |
|
55 | + $httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate); |
|
56 | + } |
|
57 | + if (isset($this->notifyUrl)) { |
|
58 | + $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
59 | + } |
|
60 | + if (isset($this->seek)) { |
|
61 | + $httpBody .= '&seek=' . $this->seek; |
|
62 | + } |
|
63 | + if (isset($this->duration)) { |
|
64 | + $httpBody .= '&duration=' . $this->duration; |
|
65 | + } |
|
56 | 66 | return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体 |
57 | 67 | } |
58 | 68 | /*######################以下是可选的参数set方法#######################*/ |
@@ -93,10 +103,13 @@ discard block |
||
93 | 103 | public function checkOptionParameters() |
94 | 104 | { |
95 | 105 | list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
96 | - if (!$valid) |
|
97 | - return array($valid, $msg, null); |
|
98 | - if (empty($this->time) || !is_int($this->time) || $this->time < 0) |
|
99 | - return array(false, "time is empty or invalid.", null); // 是否设置时间,且时间是否合法 |
|
106 | + if (!$valid) { |
|
107 | + return array($valid, $msg, null); |
|
108 | + } |
|
109 | + if (empty($this->time) || !is_int($this->time) || $this->time < 0) { |
|
110 | + return array(false, "time is empty or invalid.", null); |
|
111 | + } |
|
112 | + // 是否设置时间,且时间是否合法 |
|
100 | 113 | return $this->getOptionsHttpBody(); //返回http请求体 |
101 | 114 | } |
102 | 115 | |
@@ -108,8 +121,9 @@ discard block |
||
108 | 121 | $httpBody .= '&output=' . $this->getOutputResId(); |
109 | 122 | $httpBody .= '&time=' . $this->time; |
110 | 123 | // 可选的参数 |
111 | - if (isset($this->notifyUrl)) |
|
112 | - $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
124 | + if (isset($this->notifyUrl)) { |
|
125 | + $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
126 | + } |
|
113 | 127 | return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体 |
114 | 128 | } |
115 | 129 | |
@@ -142,14 +156,18 @@ discard block |
||
142 | 156 | /**检测参数选项是否合法*/ |
143 | 157 | public function checkOptionParameters() |
144 | 158 | { |
145 | - if (empty($this->input) || empty($this->output)) |
|
146 | - return array(false, "input or output resources is empty."); // 判断是否设置输入输出文件,或者转码模板 |
|
159 | + if (empty($this->input) || empty($this->output)) { |
|
160 | + return array(false, "input or output resources is empty."); |
|
161 | + } |
|
162 | + // 判断是否设置输入输出文件,或者转码模板 |
|
147 | 163 | list($valid, $msg) = $this->input->checkResourceInfo(true, true); //检测输入的资源信息是否合法 |
148 | - if (!$valid) |
|
149 | - return array($valid, $msg); |
|
164 | + if (!$valid) { |
|
165 | + return array($valid, $msg); |
|
166 | + } |
|
150 | 167 | list($valid, $msg) = $this->output->checkResourceInfo(true, true); //检测输入的资源信息是否合法 |
151 | - if (!$valid) |
|
152 | - return array($valid, $msg); |
|
168 | + if (!$valid) { |
|
169 | + return array($valid, $msg); |
|
170 | + } |
|
153 | 171 | return array(true, null); |
154 | 172 | } |
155 | 173 | public function getInputResId() |