@@ -21,6 +21,7 @@ class WebRtcClient {
2121 private LinkedList <PeerConnection .IceServer > iceServers = new LinkedList <>();
2222 private MediaConstraints pcConstraints = new MediaConstraints ();
2323 private MediaStream localMS ;
24+ private VideoSource videoSource ;
2425 private RTCListener mListener ;
2526 private Socket client ;
2627 private final static String TAG = WebRtcClient .class .getCanonicalName ();
@@ -111,7 +112,6 @@ private MessageHandler() {
111112 public Emitter .Listener onMessage = new Emitter .Listener () {
112113 @ Override
113114 public void call (Object ... args ) {
114- Log .d ("POUET" , "receive message " +args [0 ].toString ());
115115 JSONObject data = (JSONObject ) args [0 ];
116116 try {
117117 String from = data .getString ("from" );
@@ -262,7 +262,7 @@ public void setCamera(String height, String width){
262262 videoConstraints .mandatory .add (new MediaConstraints .KeyValuePair ("maxHeight" , height ));
263263 videoConstraints .mandatory .add (new MediaConstraints .KeyValuePair ("maxWidth" , width ));
264264
265- VideoSource videoSource = factory .createVideoSource (getVideoCapturer (), videoConstraints );
265+ videoSource = factory .createVideoSource (getVideoCapturer (), videoConstraints );
266266 AudioSource audioSource = factory .createAudioSource (new MediaConstraints ());
267267 localMS = factory .createLocalMediaStream ("ARDAMS" );
268268 localMS .addTrack (factory .createVideoTrack ("ARDAMSv0" , videoSource ));
@@ -271,6 +271,18 @@ public void setCamera(String height, String width){
271271 mListener .onLocalStream (localMS );
272272 }
273273
274+ public void stopVideoSource () {
275+ if (videoSource != null ) {
276+ videoSource .stop ();
277+ }
278+ }
279+
280+ public void restartVideoSource () {
281+ if (videoSource != null ) {
282+ videoSource .restart ();
283+ }
284+ }
285+
274286 private int findEndPoint () {
275287 for (int i = 0 ; i < MAX_PEER ; i ++) {
276288 if (!endPoints [i ]) return i ;
0 commit comments