|
1
|
|
|
<?php |
|
2
|
|
|
// |
|
3
|
|
|
// This code and all components (c) Copyright 2006 - 2018, Wowza Media Systems, LLC. All rights reserved. |
|
4
|
|
|
// This code is licensed pursuant to the Wowza Public License version 1.0, available at www.wowza.com/legal. |
|
5
|
|
|
// |
|
6
|
|
|
namespace Com\Wowza; |
|
7
|
|
|
|
|
8
|
|
|
use Com\Wowza\Entities\Application\Helpers\Settings; |
|
9
|
|
|
|
|
10
|
|
|
class Recording extends Wowza |
|
11
|
|
|
{ |
|
12
|
|
|
protected $recorderName = 'myStream'; |
|
13
|
|
|
protected $instanceName = '_definst_'; |
|
14
|
|
|
protected $recorderState = 'Waiting for stream'; |
|
15
|
|
|
protected $defaultRecorder = 'true'; |
|
16
|
|
|
protected $segmentationType = 'None'; |
|
17
|
|
|
protected $outputPath = ''; |
|
18
|
|
|
protected $baseFile = 'myrecord.mp4'; |
|
19
|
|
|
protected $fileFormat = 'MP4'; |
|
20
|
|
|
protected $fileVersionDelegateName = 'com.wowza.wms.livestreamrecord.manager.StreamRecorderFileVersionDelegate'; |
|
21
|
|
|
protected $fileTemplate = '${BaseFileName}_${RecordingStartTime}_${SegmentNumber}'; |
|
22
|
|
|
protected $segmentDuration = '900000'; |
|
23
|
|
|
protected $segmentSize = '10485760'; |
|
24
|
|
|
protected $segmentSchedule = '0 * * * * *'; |
|
25
|
|
|
protected $recordData = 'true'; |
|
26
|
|
|
protected $startOnKeyFrame = 'true'; |
|
27
|
|
|
protected $splitOnTcDiscontinuity = 'false'; |
|
28
|
|
|
protected $option = 'Version existing file'; |
|
29
|
|
|
protected $moveFirstVideoFrameToZero = 'true'; |
|
30
|
|
|
protected $currentSize = '0'; |
|
31
|
|
|
protected $currentDuration = '0'; |
|
32
|
|
|
protected $recordingStartTime = ''; |
|
33
|
|
|
|
|
34
|
|
|
public function __construct(Settings $settings, $appName = 'live', $appInstance = '_definst_') |
|
35
|
|
|
{ |
|
36
|
|
|
parent::__construct($settings); |
|
37
|
|
|
$this->restURI = $this->getHost() . '/servers/' . $this->getServerInstance() . '/vhosts/' . $this->getVHostInstance() . "/applications/{$appName}/instances/{$appInstance}/streamrecorders"; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function create( |
|
41
|
|
|
$recorderName, |
|
42
|
|
|
$instanceName, |
|
43
|
|
|
$recorderState, |
|
44
|
|
|
$defaultRecorder, |
|
45
|
|
|
$segmentationType, |
|
46
|
|
|
$outputPath, |
|
47
|
|
|
$baseFile, |
|
48
|
|
|
$fileFormat, |
|
49
|
|
|
$fileVersionDelegateName, |
|
50
|
|
|
$fileTemplate, |
|
51
|
|
|
$segmentDuration, |
|
52
|
|
|
$segmentSize, |
|
53
|
|
|
$segmentSchedule, |
|
54
|
|
|
$recordData, |
|
55
|
|
|
$startOnKeyFrame, |
|
56
|
|
|
$splitOnTcDiscontinuity, |
|
57
|
|
|
$option, |
|
58
|
|
|
$moveFirstVideoFrameToZero, |
|
59
|
|
|
$currentSize, |
|
60
|
|
|
$currentDuration, |
|
61
|
|
|
$recordingStartTime |
|
62
|
|
|
) { |
|
63
|
|
|
$this->recorderName = $recorderName; |
|
64
|
|
|
$this->instanceName = $instanceName; |
|
65
|
|
|
$this->recorderState = $recorderState; |
|
66
|
|
|
$this->defaultRecorder = $defaultRecorder; |
|
67
|
|
|
$this->segmentationType = $segmentationType; |
|
68
|
|
|
$this->outputPath = $outputPath; |
|
69
|
|
|
$this->baseFile = $baseFile; |
|
70
|
|
|
$this->fileFormat = $fileFormat; |
|
71
|
|
|
$this->fileVersionDelegateName = $fileVersionDelegateName; |
|
72
|
|
|
$this->fileTemplate = $fileTemplate; |
|
73
|
|
|
$this->segmentDuration = $segmentDuration; |
|
74
|
|
|
$this->segmentSize = $segmentSize; |
|
75
|
|
|
$this->segmentSchedule = $segmentSchedule; |
|
76
|
|
|
$this->recordData = $recordData; |
|
77
|
|
|
$this->startOnKeyFrame = $startOnKeyFrame; |
|
78
|
|
|
$this->splitOnTcDiscontinuity = $splitOnTcDiscontinuity; |
|
79
|
|
|
$this->option = $option; |
|
80
|
|
|
$this->moveFirstVideoFrameToZero = $moveFirstVideoFrameToZero; |
|
81
|
|
|
$this->currentSize = $currentSize; |
|
82
|
|
|
$this->currentDuration = $currentDuration; |
|
83
|
|
|
$this->recordingStartTime = $recordingStartTime; |
|
84
|
|
|
|
|
85
|
|
|
$response = $this->sendRequest($this->preparePropertiesForRequest(self::class), []); |
|
86
|
|
|
|
|
87
|
|
|
return $response; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function getAll() |
|
91
|
|
|
{ |
|
92
|
|
|
$this->setNoParams(); |
|
93
|
|
|
|
|
94
|
|
|
return $this->sendRequest($this->preparePropertiesForRequest(self::class), [], self::VERB_GET); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getRecorder($recorderName) |
|
98
|
|
|
{ |
|
99
|
|
|
$this->restURI = $this->restURI . '/' . $recorderName; |
|
100
|
|
|
$this->setNoParams(); |
|
101
|
|
|
|
|
102
|
|
|
return $this->sendRequest($this->preparePropertiesForRequest(self::class), [], self::VERB_GET); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function getDefaultParams($recorderName) |
|
106
|
|
|
{ |
|
107
|
|
|
$this->restURI = $this->restURI . '/' . $recorderName . '/default'; |
|
108
|
|
|
$this->setNoParams(); |
|
109
|
|
|
|
|
110
|
|
|
return $this->sendRequest($this->preparePropertiesForRequest(self::class), [], self::VERB_GET); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function stop($recorderName) |
|
114
|
|
|
{ |
|
115
|
|
|
$this->restURI = $this->restURI . '/' . $recorderName . '/actions/stopRecording'; |
|
116
|
|
|
$this->setNoParams(); |
|
117
|
|
|
|
|
118
|
|
|
return $this->sendRequest($this->preparePropertiesForRequest(self::class), [], self::VERB_PUT); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function split($recorderName) |
|
122
|
|
|
{ |
|
123
|
|
|
$this->restURI = $this->restURI . '/' . $recorderName . '/actions/splitRecording'; |
|
124
|
|
|
$this->setNoParams(); |
|
125
|
|
|
|
|
126
|
|
|
return $this->sendRequest($this->preparePropertiesForRequest(self::class), [], self::VERB_PUT); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
private function setNoParams() |
|
130
|
|
|
{ |
|
131
|
|
|
$this->addSkipParameter('recordName', true) |
|
132
|
|
|
->addSkipParameter('instanceName', true) |
|
133
|
|
|
->addSkipParameter('recorderState', true) |
|
134
|
|
|
->addSkipParameter('defaultRecorder', true) |
|
135
|
|
|
->addSkipParameter('segmentationType', true) |
|
136
|
|
|
->addSkipParameter('outputPath', true) |
|
137
|
|
|
->addSkipParameter('baseFile', true) |
|
138
|
|
|
->addSkipParameter('fileFormat', true) |
|
139
|
|
|
->addSkipParameter('fileVersionDelegateName', true) |
|
140
|
|
|
->addSkipParameter('fileTemplate', true) |
|
141
|
|
|
->addSkipParameter('segmentDuration', true) |
|
142
|
|
|
->addSkipParameter('segmentSize', true) |
|
143
|
|
|
->addSkipParameter('segmentSchedule', true) |
|
144
|
|
|
->addSkipParameter('startOnKeyFrame', true) |
|
145
|
|
|
->addSkipParameter('splitOnTcDiscontinuity', true) |
|
146
|
|
|
->addSkipParameter('option', true) |
|
147
|
|
|
->addSkipParameter('moveFirstVideoFrameToZero', true) |
|
148
|
|
|
->addSkipParameter('currentSize', true) |
|
149
|
|
|
->addSkipParameter('currentDuration', true) |
|
150
|
|
|
->addSkipParameter('recordingStartTime', true); |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|