-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStreamView.as
More file actions
151 lines (125 loc) · 4.16 KB
/
StreamView.as
File metadata and controls
151 lines (125 loc) · 4.16 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package {
import Utils;
import InfoField;
import InfoPanel;
import StreamDisplay;
import StreamController;
import flash.events.TimerEvent;
import flash.display.Sprite;
import flash.external.ExternalInterface;
public class StreamView extends Sprite {
var displays:Object;
var ctrl:StreamController;
var camInfoPanel:InfoPanel;
var serverURL:String;
var streamName:String;
var defaults:Object;
var options:Object;
/**
* Root display for streaming app
*/
public function StreamView() {
defaults = {
driver : '',
streamName : "test_" + new Date().valueOf(),
protocol: 'rtmp',
host : '',
app : 'default',
showInfo: true,
padding : 0,
display : {
w: 480,
h: 360
}
};
options = Utils.extend( defaults, stage.loaderInfo.parameters );
var a;
trace('== options ==');
for each (a in options) {
trace(a);
}
options.serverURL = setServerURL();
initView();
initConnections();
}
/**
* Initialize video displays. Override for class variants.
*/
public function initView() {
/*displays = {};
displays[options.streamName] = new StreamDisplay( options.streamName, { show_info: false } );
addChild( displays[options.streamName] );*/
}
/**
* Initialize connections. Override for class variants.
*/
public function initConnections() {
/*ctrl = new StreamController( this );
ctrl.addConnection( options.streamName, ctrl.input.cam, displays[options.streamName].vid );
ctrl.start( options.streamName, { show_info : false } );
ctrl.addConnection( options.streamName, ctrl.input.cam, serverURL );
ctrl.start( options.streamName, options.streamName );*/
}
function positionVid() {
}
/**
* Creates and places info panel for input devices
*/
function initCamInfoPanel( x=0, y=0, parent=null ) {
camInfoPanel = new InfoPanel( [
"activityLevel",
"bandwidth",
"currentFPS",
"keyFrameInterval",
"loopback",
"motionLevel",
"motionTimeout",
"quality"
] );
camInfoPanel.x = x;
camInfoPanel.y = y;
( parent ) ? parent.addChild( camInfoPanel ) : addChild( camInfoPanel );
}
/**
* Creates full media server url from options
* TODO - Have StreamController do this
*/
function setServerURL() {
var url = [options.protocol, '://', options.host, '/', options.app ].join('');
trace( 'server url =', url );
return url;
}
/**
* Updates info for devices
* TODO - Pass cam info in rather than accessing through controller
*/
public function updateCamInfo( evt:TimerEvent ) {
var field, panel,
cam = ctrl.input.cam
;
if ( ! cam || ! camInfoPanel ) {
return; }
panel = camInfoPanel.fields
for ( field in panel ) {
if ( cam[field] ) {
panel[field].value.text = cam[field];
}
}
}
/**
* Updates network status info panels
*/
public function updateStreamInfo( conn ) {
var field, panel,
display = displays[conn.name]
;
if ( ! display || ( display && ! display.infoPanel ) || ! conn.stream ) {
return;
}
panel = display.infoPanel.fields;
for ( field in panel ) {
panel[field].value.text = conn.stream[field];
}
}
}
}