|
8 | 8 | 'rington': 'ringtoneSignal' |
9 | 9 | }; |
10 | 10 |
|
| 11 | + var recorder; |
| 12 | + var recorderOpts = { |
| 13 | + callbacks: { |
| 14 | + onStartRecording: function onStartRecord() { |
| 15 | + console.log('[QB Recorder] onStartRecording'); |
| 16 | + $('.j-record').addClass('active'); |
| 17 | + }, |
| 18 | + onStopRecording: function(blob) { |
| 19 | + console.log('[QB Recorder] onStopRecording'); |
| 20 | + $('.j-record').removeClass('active'); |
| 21 | + |
| 22 | + var down = confirm('Do you want to download video?'); |
| 23 | + if(down) { |
| 24 | + recorder.download(blob, 'QB_WEBrtc_sample' + Date.now()); |
| 25 | + } |
| 26 | + } |
| 27 | + } |
| 28 | + }; |
| 29 | + |
11 | 30 | var ui = { |
12 | 31 | 'income_call': '#income_call', |
13 | 32 | 'filterSelect': '.j-filter', |
|
98 | 117 | app.callees = {}; |
99 | 118 | app.calleesAnwered = []; |
100 | 119 | app.users = []; |
101 | | - app.videoMain = 0; |
102 | 120 | }, |
103 | 121 | 'dashboard': function() { |
104 | 122 | if(_.isEmpty(app.caller)) { |
|
475 | 493 | $(document).on('click', '.j-callees__callee__video', function() { |
476 | 494 | var $that = $(this), |
477 | 495 | userId = +($(this).data('user')), |
478 | | - classesName = [], |
479 | 496 | activeClass = []; |
480 | 497 |
|
481 | 498 | if( app.currentSession.peerConnections[userId].stream && !_.isEmpty( $that.attr('src')) ) { |
|
519 | 536 | app.currentSession.mute( $btn.data('target') ); |
520 | 537 | } |
521 | 538 | } |
522 | | - }); |
| 539 | + }); |
| 540 | + |
| 541 | + /** Video recording */ |
| 542 | + $(document).on('click', '.j-record', function() { |
| 543 | + var $btn = $(this), |
| 544 | + isActive = $btn.hasClass('active'); |
| 545 | + |
| 546 | + if(_.isEmpty(app.currentSession)) { |
| 547 | + return false; |
| 548 | + } else if(QB.Recorder.isAvailable()) { |
| 549 | + if(!isActive){ |
| 550 | + var connections = app.currentSession.peerConnections, |
| 551 | + connection = connections[app.mainVideo], |
| 552 | + connectionsCount = Object.keys(connections).length; |
| 553 | + |
| 554 | + if (!connection || connectionsCount !== 1){ |
| 555 | + return false; |
| 556 | + } |
| 557 | + console.info('HERE'); |
| 558 | + recorder = new QB.Recorder(connection.stream, recorderOpts); |
| 559 | + recorder.start(); |
| 560 | + } else { |
| 561 | + recorder.stop(); |
| 562 | + } |
| 563 | + } |
| 564 | + }); |
523 | 565 |
|
524 | 566 | /** LOGOUT */ |
525 | 567 | $(document).on('click', '.j-logout', function() { |
|
632 | 674 | } else { |
633 | 675 | app.helpers.notifyIfUserLeaveCall(session, session.opponentsIDs[0], 'closed'); |
634 | 676 | } |
| 677 | + |
| 678 | + if(QB.Recorder && QB.Recorder.isAvailable()) { |
| 679 | + recorder.stop(); |
| 680 | + } |
| 681 | + |
635 | 682 | }; |
636 | 683 |
|
637 | 684 | QB.webrtc.onUserNotAnswerListener = function onUserNotAnswerListener(session, userId) { |
|
711 | 758 | console.groupEnd(); |
712 | 759 |
|
713 | 760 | app.helpers.notifyIfUserLeaveCall(session, userId, 'hung up the call', 'Hung Up'); |
| 761 | + |
| 762 | + recorder.stop(); |
714 | 763 | }; |
715 | 764 |
|
716 | 765 | QB.webrtc.onAcceptCallListener = function onAcceptCallListener(session, userId, extension) { |
|
743 | 792 | console.group('onRemoteStreamListener.'); |
744 | 793 | console.log('userId: ', userId); |
745 | 794 | console.log('Session: ', session); |
| 795 | + console.log('Stream: ', stream); |
746 | 796 | console.groupEnd(); |
747 | 797 |
|
748 | 798 | var state = app.currentSession.connectionStateForUser(userId), |
|
0 commit comments