@@ -143,7 +143,6 @@ var originalMediaStreamTrack = MediaStreamTrack.originalMediaStreamTrack;
143
143
144
144
/**
145
145
* Expose the MediaStream class.
146
- * Make MediaStream be a Blob so it can be consumed by URL.createObjectURL().
147
146
*/
148
147
function MediaStream ( arg , id ) {
149
148
debug ( 'new MediaStream(arg) | [arg:%o]' , arg ) ;
@@ -2470,7 +2469,6 @@ function dump() {
2470
2469
2471
2470
} ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
2472
2471
} , { "./MediaStream" :4 , "./MediaStreamTrack" :6 , "./RTCIceCandidate" :9 , "./RTCPeerConnection" :10 , "./RTCSessionDescription" :11 , "./enumerateDevices" :14 , "./getUserMedia" :15 , "./videoElementsHandler" :17 , "cordova/exec" :undefined , "debug" :18 , "domready" :20 } ] , 17 :[ function ( _dereq_ , module , exports ) {
2473
- ( function ( global ) {
2474
2472
/**
2475
2473
* Expose a function that must be called when the library is loaded.
2476
2474
* And also a helper function.
@@ -2491,12 +2489,6 @@ var
2491
2489
* Local variables.
2492
2490
*/
2493
2491
2494
- // RegExp for MediaStream blobId.
2495
- MEDIASTREAM_ID_REGEXP = new RegExp ( / ^ M e d i a S t r e a m _ / ) ,
2496
-
2497
- // RegExp for Blob URI.
2498
- BLOB_URI_REGEX = new RegExp ( / ^ b l o b : / ) ,
2499
-
2500
2492
// Dictionary of MediaStreamRenderers (provided via module argument).
2501
2493
// - key: MediaStreamRenderer id.
2502
2494
// - value: MediaStreamRenderer.
@@ -2517,8 +2509,8 @@ var
2517
2509
// HTML video element.
2518
2510
video = mutation . target ;
2519
2511
2520
- // .src or . srcObject removed.
2521
- if ( ! video . src && ! video . srcObject ) {
2512
+ // .srcObject removed.
2513
+ if ( ! video . srcObject ) {
2522
2514
// If this video element was previously handling a MediaStreamRenderer, release it.
2523
2515
releaseMediaStreamRenderer ( video ) ;
2524
2516
continue ;
@@ -2643,13 +2635,13 @@ function videoElementsHandler(_mediaStreams, _mediaStreamRenderers) {
2643
2635
function observeVideo ( video ) {
2644
2636
debug ( 'observeVideo()' ) ;
2645
2637
2646
- // If the video already has a src/ srcObject property but is not yet handled by the plugin
2638
+ // If the video already has a srcObject property but is not yet handled by the plugin
2647
2639
// then handle it now.
2648
- if ( ( video . src || video . srcObject ) && ! video . _iosrtcMediaStreamRendererId ) {
2640
+ if ( ( video . srcObject ) && ! video . _iosrtcMediaStreamRendererId ) {
2649
2641
handleVideo ( video ) ;
2650
2642
}
2651
2643
2652
- // Add .src observer to the video element.
2644
+ // Add .srcObject observer to the video element.
2653
2645
videoObserver . observe ( video , {
2654
2646
// Set to true if additions and removals of the target node's child elements (including text
2655
2647
// nodes) are to be observed.
@@ -2668,16 +2660,7 @@ function observeVideo(video) {
2668
2660
characterDataOldValue : false ,
2669
2661
// Set to an array of attribute local names (without namespace) if not all attribute mutations
2670
2662
// need to be observed.
2671
- attributeFilter : [ 'src' , 'srcObject' ]
2672
- } ) ;
2673
-
2674
- // Intercept video 'error' events if it's due to the attached MediaStream.
2675
- video . addEventListener ( 'error' , function ( event ) {
2676
- if ( video . error . code === global . MediaError . MEDIA_ERR_SRC_NOT_SUPPORTED && BLOB_URI_REGEX . test ( video . src ) ) {
2677
- debug ( 'stopping "error" event propagation for video element' ) ;
2678
-
2679
- event . stopImmediatePropagation ( ) ;
2680
- }
2663
+ attributeFilter : [ 'srcObject' ]
2681
2664
} ) ;
2682
2665
}
2683
2666
@@ -2688,51 +2671,10 @@ function observeVideo(video) {
2688
2671
2689
2672
function handleVideo ( video ) {
2690
2673
var
2691
- xhr = new XMLHttpRequest ( ) ,
2692
2674
stream ;
2693
2675
2694
- // The app has set video.src.
2695
- if ( video . src ) {
2696
- xhr . open ( 'GET' , video . src , true ) ;
2697
- xhr . responseType = 'blob' ;
2698
- xhr . onload = function ( ) {
2699
- if ( xhr . status !== 200 ) {
2700
- // If this video element was previously handling a MediaStreamRenderer, release it.
2701
- releaseMediaStreamRenderer ( video ) ;
2702
-
2703
- return ;
2704
- }
2705
-
2706
- var reader = new FileReader ( ) ;
2707
-
2708
- // Some versions of Safari fail to set onloadend property, some others do not react
2709
- // on 'loadend' event. Try everything here.
2710
- try {
2711
- reader . onloadend = onloadend ;
2712
- } catch ( error ) {
2713
- reader . addEventListener ( 'loadend' , onloadend ) ;
2714
- }
2715
- reader . readAsText ( xhr . response ) ;
2716
-
2717
- function onloadend ( ) {
2718
- var mediaStreamBlobId = reader . result ;
2719
-
2720
- // The retrieved URL does not point to a MediaStream.
2721
- if ( ! mediaStreamBlobId || typeof mediaStreamBlobId !== 'string' || ! MEDIASTREAM_ID_REGEXP . test ( mediaStreamBlobId ) ) {
2722
- // If this video element was previously handling a MediaStreamRenderer, release it.
2723
- releaseMediaStreamRenderer ( video ) ;
2724
-
2725
- return ;
2726
- }
2727
-
2728
- provideMediaStreamRenderer ( video , mediaStreamBlobId ) ;
2729
- }
2730
- } ;
2731
- xhr . send ( ) ;
2732
- }
2733
-
2734
2676
// The app has set video.srcObject.
2735
- else if ( video . srcObject ) {
2677
+ if ( video . srcObject ) {
2736
2678
stream = video . srcObject ;
2737
2679
2738
2680
if ( ! stream . getBlobId ( ) ) {
@@ -2805,7 +2747,6 @@ function provideMediaStreamRenderer(video, mediaStreamBlobId) {
2805
2747
} ) ;
2806
2748
}
2807
2749
2808
-
2809
2750
function releaseMediaStreamRenderer ( video ) {
2810
2751
if ( ! video . _iosrtcMediaStreamRendererId ) {
2811
2752
return ;
@@ -2826,7 +2767,6 @@ function releaseMediaStreamRenderer(video) {
2826
2767
delete video . readyState ;
2827
2768
}
2828
2769
2829
- } ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
2830
2770
} , { "./MediaStreamRenderer" :5 , "debug" :18 } ] , 18 :[ function ( _dereq_ , module , exports ) {
2831
2771
( function ( process ) {
2832
2772
/* eslint-env browser */
0 commit comments