I want to access streamObject outside the getUserMedia. Here are the codes. Normally you would run script functions inside success callback but I don't to do that because the function getUserMedia is used many times and I don't want to repeat coding same function.
 var streamObject;
  requestDevices = {
     media:function(){
         navigator.getUserMedia(
             {video:true, audio:true},
             function(stream){
                 streamObject = stream; 
                 return streamObject //not working
            });
      }
  };
 /
stream  = {
   // I need the streamObject here
   startStream:function(stream){
         pc.addStream(streamObject);
       //blah blah blah
   }
}
I also tried code below, but did not work because the myCallback needs stream in the first place..
media:function(myCallback){
         navigator.getUserMedia(
             {video:true, audio:true},
             function(stream){
                 streamObject = stream; 
                 return streamObject;
                stream.startStream(streamObject);
            });
      }
 
     
    