@@ -54,24 +54,16 @@ enum ScaleMode {
5454typedef WOWZStatusCallback = Function (WOWZStatus );
5555typedef WOWZBroadcastStatusCallback = Function (WOWZBroadcastStatus );
5656
57- abstract class OnWOWZBroadcastStatusCallback {
57+ abstract class OnWOWZBroadcastStatusCallback {
5858 void onWZStatus (WOWZBroadcastStatus status);
59+
5960 void onWZError (WOWZBroadcastStatus status);
6061}
6162
6263class WOWZCameraView extends StatefulWidget {
6364 WOWZCameraView (
6465 {@required this .controller,
6566 @required this .apiLicenseKey,
66- @required this .hostAddress,
67- @required this .portNumber,
68- @required this .applicationName,
69- @required this .streamName,
70- this .username,
71- this .password,
72- this .wowzSize,
73- this .wowzMediaConfig,
74- this .scaleMode = ScaleMode .RESIZE_TO_ASPECT , this .fps, this .bps, this .khz,
7567 this .statusCallback,
7668 this .broadcastStatusCallback});
7769
@@ -84,24 +76,6 @@ class WOWZCameraView extends StatefulWidget {
8476 final WOWZBroadcastStatusCallback broadcastStatusCallback;
8577
8678 final String apiLicenseKey;
87-
88- // Set the connection properties for the target Wowza Streaming Engine server or Wowza Streaming Cloud live stream
89- final String hostAddress;
90- final int portNumber;
91- final String applicationName;
92- final String streamName;
93-
94- //authentication
95- final String username;
96- final String password;
97-
98- final WOWZSize wowzSize;
99- final WOWZMediaConfig wowzMediaConfig;
100- final ScaleMode scaleMode;
101-
102- final int fps;
103- final int bps;
104- final int khz;
10579}
10680
10781class _WOWZCameraViewState extends State <WOWZCameraView > {
@@ -116,18 +90,21 @@ class _WOWZCameraViewState extends State<WOWZCameraView> {
11690 print ('controller event: ${widget .controller .value .event }' );
11791 switch (widget.controller.value.event) {
11892 case _flashlight:
119- if (defaultTargetPlatform == TargetPlatform .android)
93+ if (defaultTargetPlatform == TargetPlatform .android)
12094 _channel? .invokeMethod (
12195 widget.controller.value.event, widget.controller.value.value);
12296 else
123- _channel? .invokeMethod (widget.controller.value.value? _flashlightOn: _flashlightOff);
97+ _channel? .invokeMethod (widget.controller.value.value
98+ ? _flashlightOn
99+ : _flashlightOff);
124100 break ;
125101 case _muted:
126- if (defaultTargetPlatform == TargetPlatform .android)
102+ if (defaultTargetPlatform == TargetPlatform .android)
127103 _channel? .invokeMethod (
128104 widget.controller.value.event, widget.controller.value.value);
129105 else
130- _channel? .invokeMethod (widget.controller.value.value? _mutedOn: _mutedOff);
106+ _channel? .invokeMethod (
107+ widget.controller.value.value ? _mutedOn : _mutedOff);
131108 break ;
132109 case _startPreview:
133110 case _startPreview:
@@ -169,10 +146,13 @@ class _WOWZCameraViewState extends State<WOWZCameraView> {
169146 '$defaultTargetPlatform is not yet supported by the text_view plugin' );
170147 }
171148
172- _onPlatformViewCreated (int viewId){
149+ _onPlatformViewCreated (int viewId) {
173150 if (_viewId != viewId || _channel == null ) {
174151 _viewId = viewId;
152+
175153 _channel = MethodChannel ("${_camera_view_channel }_$viewId " );
154+ widget.controller? ._setChannel (_channel);
155+
176156 _channel.setMethodCallHandler ((call) async {
177157 print ('wowz: status: ${call .arguments }' );
178158 switch (call.method) {
@@ -192,52 +172,12 @@ class _WOWZCameraViewState extends State<WOWZCameraView> {
192172 break ;
193173 }
194174 });
195- widget.controller? ._setChannel (_channel);
196-
197175 // license key gocoder sdk
198176 _channel.invokeMethod (_apiLicenseKey, widget.apiLicenseKey);
199- // Set the connection properties for the target Wowza Streaming Engine server or Wowza Streaming Cloud live stream
200- if (widget.hostAddress != null && widget.hostAddress.isNotEmpty) {
201- _channel.invokeMethod (_hostAddress, widget.hostAddress);
202- }
203- if (widget.portNumber != null ) {
204- _channel.invokeMethod (_portNumber, widget.portNumber);
205- }
206- if (widget.applicationName != null && widget.applicationName.isNotEmpty) {
207- _channel.invokeMethod (_applicationName, widget.applicationName);
208- }
209- if (widget.streamName != null && widget.streamName.isNotEmpty) {
210- _channel.invokeMethod (_streamName, widget.streamName);
211- }
212- //authentication
213- if (widget.username != null ) {
214- _channel.invokeMethod (_username, widget.username);
215- }
216- if (widget.password != null ) {
217- _channel.invokeMethod (_password, widget.password);
218- }
219- if (widget.wowzSize != null ) {
220- _channel.invokeMethod (
221- _wowzSize, "${widget .wowzSize .width }/${widget .wowzSize .height }" );
222- }
223- if (widget.wowzMediaConfig != null ) {
224- _channel.invokeMethod (
225- _wowzMediaConfig, widget.wowzMediaConfig.toString ());
226- }
227- if (widget.scaleMode != null ) {
228- _channel.invokeMethod (_scaleMode, widget.scaleMode.toString ());
229- }
230- if (widget.fps!= null ){
231- _channel.invokeListMethod (_fps,widget.fps);
232- }
233- if (widget.bps != null ){
234- _channel.invokeListMethod (_bps,widget.bps);
235- }
236- if (widget.khz != null ){
237- _channel.invokeListMethod (_bps,widget.bps);
238- }
239177
240- _channel.invokeListMethod (_initGoCoder);
178+ if (widget.controller.configIsWaiting) {
179+ widget.controller.resetConfig ();
180+ }
241181 }
242182 }
243183}
0 commit comments