8000 Recording does not work · Issue #111 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

Recording does not work #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hiteshjoshi opened this issue Jul 13, 2019 · 3 comments
Closed

Recording does not work #111

hiteshjoshi opened this issue Jul 13, 2019 · 3 comments
Labels
🐛bug Something isn't working

Comments

@hiteshjoshi
Copy link
hiteshjoshi commented Jul 13, 2019

Recording does not work

Follow the example , https://github.com/cloudwebrtc/flutter-webrtc/blob/master/example/lib/src/get_user_media_sample.dart

Expected behaviour
E/MethodChannel#FlutterWebRTC.Method(25723): Failed to handle method call
E/MethodChannel#FlutterWebRTC.Method(25723): java.lang.IllegalArgumentException: Unsupported value: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
E/MethodChannel#FlutterWebRTC.Method(25723): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:294)
E/MethodChannel#FlutterWebRTC.Method(25723): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70)
E/MethodChannel#FlutterWebRTC.Method(25723): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
E/MethodChannel#FlutterWebRTC.Method(25723): at com.cloudwebrtc.webrtc.utils.AnyThreadResult.lambda$error$1(AnyThreadResult.java:23)
E/MethodChannel#FlutterWebRTC.Method(25723): at com.cloudwebrtc.webrtc.utils.-$$Lambda$AnyThreadResult$ccKxFpM2amkNZNKH8YO8t8OktKE.run(Unknown Source:8)
E/MethodChannel#FlutterWebRTC.Method(25723): at com.cloudwebrtc.webrtc.utils.AnyThreadResult.post(AnyThreadResult.java:33)
E/MethodChannel#FlutterWebRTC.Method(25723): at com.cloudwebrtc.webrtc.utils.AnyThreadResult.error(AnyThreadResult.java:23)
E/MethodChannel#FlutterWebRTC.Method(25723): at com.cloudwebrtc.webrtc.FlutterWebRTCPlugin.onMethodCall(FlutterWebRTCPlugin.java:344)
E/MethodChannel#FlutterWebRTC.Method(25723): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#FlutterWebRTC.Method(25723): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:90)
E/MethodChannel#FlutterWebRTC.Method(25723): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:234)
E/MethodChannel#FlutterWebRTC.Method(25723): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#FlutterWebRTC.Method(25723): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#FlutterWebRTC.Method(25723): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#FlutterWebRTC.Method(25723): at android.app.ActivityThread.main(ActivityThread.java:6762)
E/MethodChannel#FlutterWebRTC.Method(25723): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#FlutterWebRTC.Method(25723): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#FlutterWebRTC.Method(25723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter (25723): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Unsupported value: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference, null)
E/flutter (25723): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (25723): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter (25723):
E/flutter (25723): #2 MediaRecorder.start (package:flutter_webrtc/media_recorder.dart:24:34)
E/flutter (25723):

Platform information

[✓] Flutter (Channel master, v1.7.5-pre.15, on Mac OS X 10.14.5 18F132, locale en-IN)
• Flutter version 1.7.5-pre.15 at /Users/hitesh/flutter
• Framework revision 09c09bf (4 weeks ago), 2019-06-16 21:52:44 -0700
• Engine revision 466a1d848d
• Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/hitesh/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
! CocoaPods out of date (1.6.0 is recommended).
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To upgrade:
brew upgrade cocoapods
pod setup

[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4

[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 31.3.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.36.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.2.0

[✓] Connected device (2 available)
• Mi A1 • 654564314654 • android-arm64 • Android 9 (API 28)
• Hitesh’s iPhone • 6787yuyityuitiuyiftugtyuguytughuyu • ios • iOS 12.3.2

! Doctor found issues in 1 category.

@cloudwebrtc
Copy link
Member

This seems to be a bug.

@cloudwebrtc cloudwebrtc added the 🐛bug Something isn't working label Jul 26, 2019
@chanakiyan
Copy link

You just add RecorderAudioChannel like this....
await mRecorder.start(localFilePath, localRecorderId, videoTrack: videoTrack, audioChannel: RecorderAudioChannel.INPUT);

@M4H3NDR4N
Copy link
M4H3NDR4N commented Apr 2, 2020

`
Check startScreenRecorder and stopScreenRecorder for recording.
It works for me

import 'package:flutter/material.dart';
mport 'dart:async';
import '../Utils/signaling.dart';

import 'package:flutter_webrtc/webrtc.dart';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:convert';
import 'dart:async';
import 'package:flutter/services.dart';

import 'package:collection/collection.dart';
import 'dart:io';

import 'package:quiver/async.dart';
import 'dart:core';

class VideoCall extends StatefulWidget {
final userInfo;
VideoCall({Key key, this.userInfo}) : super(key: key);
@OverRide
_VideoCallState createState() => _VideoCallState();
}

class _VideoCallState extends State {
bool videoCallLoading = false;
Signaling _signaling;
List _peers;
var _selfId;
RTCVideoRenderer _localRenderer = new RTCVideoRenderer();
RTCVideoRenderer _remoteRenderer = new RTCVideoRenderer();
bool _inCalling = false;
MediaRecorder media = MediaRecorder();

final String serverIP = 'localhost';

@OverRide
void initState() {
super.initState();
print('widget.userInfo.userInfo.contact');
print(widget.userInfo.userInfo.contact);
initRenderers();
// getPermissions();
_connect();
}

initRenderers() async {
await _localRenderer.initialize();
await _remoteRenderer.initialize();
}

@OverRide
deactivate() {
super.deactivate();
if (_signaling != null) {
print("Close");
_signaling.close();
}
_localRenderer.dispose();
_remoteRenderer.dispose();
}

void _connect() async {
if (_signaling == null) {
String room = widget.userInfo.userInfo.type == 'doctor'
? widget.userInfo.userInfo.contact.toString()
: widget.userInfo.contact.toString();
_signaling = new Signaling(
serverIP,
widget.userInfo.userInfo.contact.toString(),
widget.userInfo.userInfo.name,
widget.userInfo.userInfo.type)
..connect();
print(_signaling);
_signaling.onStateChange = (SignalingState state) {
switch (state) {
case SignalingState.CallStateNew:
this.setState(() {
_inCalling = true;
});
break;
case SignalingState.CallStateBye:
this.setState(() {
// _localRenderer = null;
// _remoteRenderer = null;
_localRenderer.srcObject = null;
_remoteRenderer.srcObject = null;
_inCalling = false;
});
break;
case SignalingState.CallStateInvite:
case SignalingState.CallStateConnected:
case SignalingState.CallStateRinging:
case SignalingState.ConnectionClosed:
case SignalingState.ConnectionError:
case SignalingState.ConnectionOpen:
break;
}
};

  _signaling.onPeersUpdate = ((event) {
    this.setState(() {
      _selfId = event['self'];
      _peers = event['peers'];
    });
  });

  _signaling.onLocalStream = ((stream) {
    _localRenderer.srcObject = stream;
  
  });

  _signaling.onAddRemoteStream = ((stream) {
    _remoteRenderer.srcObject = stream;
    
  });

  _signaling.onRemoveRemoteStream = ((stream) {
    _remoteRenderer.srcObject = null;
  });
}

}

final Map<String, dynamic> mediaConstraints = {
'audio': true,
'video': {
'mandatory': {
'minWidth': '640', // Provide your own width, height and frame rate here
'minHeight': '480',
'minFrameRate': '30',
},
'facingMode': 'user',
'optional': [],
}
};

_startScreenRecorder() async {
MediaStream stream = await navigator.getDisplayMedia(mediaConstraints);

final Directory appDirectory = Directory('/storage/emulated/0/DCIM/');
final String videoDirectory = '${appDirectory.path}';
await Directory(videoDirectory).create(recursive: true);

final String currentTime = DateTime.now().millisecondsSinceEpoch.toString();
final String filePath = '$videoDirectory/${currentTime}.mp4';
var videoTracks = stream.getVideoTracks();
// var audioTracks = stream.getAudioTracks();
media.start(filePath,
    videoTrack: videoTracks.first,
    audioChannel: RecorderAudioChannel.OUTPUT);

}

_stopScreenRecorder() async {
media.stop();
}

_invitePeer(context, peerId, use_screen) async {
if (_signaling != null && peerId != _selfId) {
_signaling.invite(peerId, 'video', use_screen);
// _startScreenRecorder();
}
}

_hangUp() async {
if (_signaling != null) {
_signaling.bye();
}
}

_uploadVideo() async {
_hangUp();
_stopScreenRecorder();
Future.delayed(
Duration(seconds: 2),
() => {
});
}

_switchCamera() {
_signaling.switchCamera();
}

_muteMic() {}

_buildRow(context, peer) {
var self = (peer['id'] == _selfId);
return ListBody(children: [
ListTile(
title: Text(self
? peer['name'] + '[Your self] '
: peer['name'] + '[' + peer['user_agent'] + ']'),
onTap: null,
trailing: new SizedBox(
width: 100.0,
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(Icons.videocam),
onPressed: () => _invitePeer(context, peer['id'], false),
tooltip: 'Video Calling',
),
IconButton(
icon: const Icon(Icons.screen_share),
onPressed: () => _invitePeer(context, peer['id'], true),
tooltip: 'Screen Sharing',
)
])),
subtitle: Text('id: ' + peer['id']),
),
Divider()
]);
}

@OverRide
Widget build(BuildContext context) {
final themeStyle = Theme.of(context);
final screen = MediaQuery.of(context);
return Scaffold(
appBar: AppBar(),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: _inCalling
? Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
RaisedButton(
padding:
EdgeInsets.symmetric(vertical: 5.0, horizontal: 50.0),
child: Text(
"END CALL",
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: theme.primaryFontWeight,
fontFamily: theme.primaryTextFamily,
fontSize: theme.primaryTextFontSize),
),
textColor: Colors.white,
color: themeStyle.buttonColor,
onPressed: _hangUp,
),
RaisedButton(

                child: Row(
                  children: <Widget>[
                    Icon(
                      Icons.file_upload,
                      size: 30.0,
                    ),
                    Text(
                      "UPLOAD",
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontWeight: theme.primaryFontWeight,
                          fontFamily: theme.primaryTextFamily,
                          fontSize: theme.primaryTextFontSize),
                    ),
                  ],
                ),
                textColor: Colors.black,
                color: Colors.white,
                onPressed: _uploadVideo,
              ),
             
            ])
      : null,
  body: _inCalling
      ? OrientationBuilder(builder: (context, orientation) {
          return new Container(
            child: new Stack(children: <Widget>[
              new Positioned(
                  left: 0.0,
                  right: 0.0,
                  top: 0.0,
                  bottom: 0.0,
                  child: new Container(
                    margin: new EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
                    width: screen.size.width,
                    height: screen.size.height,
                    child: new RTCVideoView(_remoteRenderer),
                    decoration: new BoxDecoration(color: Colors.black54),
                  )),
              new Positioned(
                left: 20.0,
                top: 20.0,
                child: new Container(
                  width: orientation == Orientation.portrait ? 90.0 : 120.0,
                  height:
                      orientation == Orientation.portrait ? 120.0 : 90.0,
                  child: new RTCVideoView(_localRenderer),
                  decoration: new BoxDecoration(color: Colors.black54),
                ),
              ),
            ]),
          );
        })
      : new ListView.builder(
          shrinkWrap: true,
          padding: const EdgeInsets.all(0.0),
          itemCount: (_peers != null ? _peers.length : 0),
          itemBuilder: (context, i) {
            return _buildRow(context, _peers[i]);
          }),
);

}
}
`

@cloudwebrtc cloudwebrtc moved this to Done in V2.0 Apr 13, 2023
@cloudwebrtc cloudwebrtc added this to V2.0 Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

4 participants
0