zhaojs
2023-06-01 802997e673d862ba81c6908a6ab05d9282de596e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
 
namespace OSS\Model;
 
 
/**
 * Class LiveChannelConfig
 * @package OSS\Model
 */
class LiveChannelConfig implements XmlConfig
{
    public function __construct($option = array())
    {
        if (isset($option['description'])) {
            $this->description = $option['description'];
        }
        if (isset($option['status'])) {
            $this->status = $option['status'];
        }
        if (isset($option['type'])) {
            $this->type = $option['type'];
        }
        if (isset($option['fragDuration'])) {
            $this->fragDuration = $option['fragDuration'];
        }
        if (isset($option['fragCount'])) {
            $this->fragCount = $option['fragCount'];
        }
        if (isset($option['playListName'])) {
            $this->playListName = $option['playListName'];
        }
    }
 
    public function getDescription()
    {
        return $this->description;
    }
 
    public function getStatus()
    {
        return $this->status;
    }
 
    public function getType()
    {
        return $this->type;
    }
 
    public function getFragDuration()
    {
        return $this->fragDuration;
    }
 
    public function getFragCount()
    {
        return $this->fragCount;
    }
 
    public function getPlayListName()
    {
        return $this->playListName;
    }
 
    public function parseFromXml($strXml)
    {
        $xml = simplexml_load_string($strXml);
        $this->description = strval($xml->Description);
        $this->status = strval($xml->Status);
        $target = $xml->Target;
        $this->type = strval($target->Type);
        $this->fragDuration = intval($target->FragDuration);
        $this->fragCount = intval($target->FragCount);
        $this->playListName = strval($target->PlayListName);
    }
 
    public function serializeToXml()
    {
        $strXml = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<LiveChannelConfiguration>
</LiveChannelConfiguration>
EOF;
        $xml = new \SimpleXMLElement($strXml);
        if (isset($this->description)) {
            $xml->addChild('Description', $this->description);
        }
 
        if (isset($this->status)) {
            $xml->addChild('Status', $this->status);
        }
 
        $node = $xml->addChild('Target');
        $node->addChild('Type', $this->type);
 
        if (isset($this->fragDuration)) {
            $node->addChild('FragDuration', $this->fragDuration);
        }
 
        if (isset($this->fragCount)) {
            $node->addChild('FragCount', $this->fragCount);
        }
 
        if (isset($this->playListName)) {
            $node->addChild('PlayListName', $this->playListName);
        }
 
        return $xml->asXML();
    }
 
    public function __toString()
    {
        return $this->serializeToXml();
    }
    
    private $description;
    private $status = "enabled";
    private $type;
    private $fragDuration = 5;
    private $fragCount = 3;
    private $playListName = "playlist.m3u8";
}