| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace SquareetLabs\LaravelOpenVidu; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use JsonSerializable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Class IPCameraOptions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @package SquareetLabs\LaravelOpenVidu | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | class IPCameraOptions implements JsonSerializable, StreamInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     /** @var  string */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     private $rtspUri; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /** @var  string */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     private $type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** @var  bool */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     private $adaptativeBitrate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** @var  bool */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     private $onlyPlayWithSubscribers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** @var  string */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * IPCameraOptions constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * @param  string  $rtspUri | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @param  string|null  $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @param  bool|null  $adaptativeBitrate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @param  bool|null  $onlyPlayWithSubscribers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @param  string|null  $data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function __construct(string $rtspUri, ?string $type = null, ?bool $adaptativeBitrate = true, ?bool $onlyPlayWithSubscribers = true, ?string $data = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->rtspUri = $rtspUri; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->type = $type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->adaptativeBitrate = $adaptativeBitrate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->onlyPlayWithSubscribers = $onlyPlayWithSubscribers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->data = $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * Convert the model instance to JSON. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @param  int  $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function toJson($options = 0): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         return json_encode($this->jsonSerialize(), $options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * Specify data which should be serialized to JSON | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * @link https://php.net/manual/en/jsonserializable.jsonserialize.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @return mixed data which can be serialized by <b>json_encode</b>, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * which is a value of any type other than a resource. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @since 5.4.0 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 59 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     public function jsonSerialize() | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |         return $this->toArray(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * Convert the model instance to an array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     public function toArray(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $array = ['rtspUri' => $this->rtspUri, 'type' => $this->type, 'adaptativeBitrate' => $this->adaptativeBitrate, 'onlyPlayWithSubscribers' => $this->onlyPlayWithSubscribers, 'data' => $this->data]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         foreach ($array as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             if (is_null($value) || $value == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 unset($array[$key]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         return $array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     /** @return  string */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     public function getRtspUri() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         return $this->rtspUri; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     /** @return  string */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     public function getType() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         return $this->type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     /** @return  bool */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     public function getAdaptativeBitrate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         return $this->adaptativeBitrate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     /** @return  bool */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     public function getOnlyPlayWithSubscribers() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         return $this->onlyPlayWithSubscribers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     /** @return  string */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     public function getData() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         return $this->data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 110 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 111 |  |  |  |