瀏覽代碼

added Elo C903IP camera

tags/0.1.3^0
Robin Thoni 8 年之前
父節點
當前提交
9b7a58d319
共有 2 個檔案被更改,包括 49 行新增2 行删除
  1. 48
    0
      app/Http/Business/Cameras/Elro/C903IP.php
  2. 1
    2
      app/Http/Business/Cameras/Trendnet/TVIP311PI.php

+ 48
- 0
app/Http/Business/Cameras/Elro/C903IP.php 查看文件

@@ -0,0 +1,48 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 8/21/16
6
+ * Time: 3:25 PM
7
+ */
8
+
9
+namespace App\Http\Business\Cameras\Elro;
10
+
11
+
12
+use App\Http\Business\Cameras\AbstractCamera;
13
+use App\Http\DBO\CamerasDbo;
14
+use GuzzleHttp\Client;
15
+use Luticate\Utils\LuLog;
16
+
17
+class C903IP extends AbstractCamera
18
+{
19
+    const URI = "/snapshot.cgi";
20
+
21
+    private $_client;
22
+    private $_url;
23
+
24
+    public function __construct(CamerasDbo $camera)
25
+    {
26
+        parent::__construct($camera);
27
+        $this->_client = new Client();
28
+        $data = $camera->getData();
29
+        $this->_url = "http://" . $data["Host"] . ":" . $data["Port"] . self::URI;
30
+    }
31
+
32
+    public function prepareImage()
33
+    {
34
+        $username = $this->_camera->getData()["Username"];
35
+        $passwd = $this->_camera->getData()["Password"];
36
+
37
+        try {
38
+            $response = $this->_client->request('GET', $this->_url, ['auth' => [
39
+                $username,
40
+                $passwd
41
+            ]]);
42
+            $data = (string)$response->getBody();
43
+            $this->_image = $this->_imagine->load($data);
44
+        } catch (\Exception $e) {
45
+            LuLog::log($e);
46
+        }
47
+    }
48
+}

+ 1
- 2
app/Http/Business/Cameras/Trendnet/TVIP311PI.php 查看文件

@@ -28,7 +28,6 @@ class TVIP311PI extends AbstractCamera
28 28
         $this->_client = new Client();
29 29
         $data = $camera->getData();
30 30
         $this->_url = "http://" . $data["Host"] . ":" . $data["Port"] . self::URI;
31
-        $this->_options = [];
32 31
     }
33 32
 
34 33
     public function prepareImage()
@@ -42,7 +41,7 @@ class TVIP311PI extends AbstractCamera
42 41
         $nonce = "";
43 42
 
44 43
         try {
45
-            $this->_client->request('GET', $this->_url, $this->_options);
44
+            $this->_client->request('GET', $this->_url);
46 45
         } catch (RequestException $e) {
47 46
             $response = $e->getResponse();
48 47
             if ($response->getStatusCode() == 401) {

Loading…
取消
儲存