Specialisation for the MediaPeer API surface
357243
function makeMediaPeerProxy (api) {
    api.setStream = function(stream, completion) {
      api._.setStream(stream);

      if (completion) {
        if (stream.hasVideo()) {
          // FIX ME renderingStarted currently doesn't first
          // api.once('renderingStarted', completion);
          var verifyStream = function() {
            if (!api._) {
              completion(new $.Error('The plugin went away before the stream could be bound.'));
              return;
            }

            if (api._.videoWidth > 0) {
              // This fires a little too soon.
              setTimeout(completion, 200);
            }
            else {
              setTimeout(verifyStream, 500);
            }
          };

          setTimeout(verifyStream, 500);
        }
        else {
          // TODO Investigate whether there is a good way to detect
          // when the audio is ready. Does it even matter?

          // This fires a little too soon.
          setTimeout(completion, 200);
        }
      }

      return api;
    };

    return api;
  }
8732
function parseStatsOldAPI (peerConnection,
                                                      prevStats,
                                                      currentStats,
                                                      completion) {

      /* this parses a result if there it contains the video bitrate */
      var parseVideoStats = function (result) {
            if (result.stat('googFrameRateSent')) {
              currentStats.videoSentBytes = Number(result.stat('bytesSent'));
              currentStats.videoSentPackets = Number(result.stat('packetsSent'));
              currentStats.videoSentPacketsLost = Number(result.stat('packetsLost'));
              currentStats.videoRtt = Number(result.stat('googRtt'));
              currentStats.videoFrameRate = Number(result.stat('googFrameRateInput'));
              currentStats.videoWidth = Number(result.stat('googFrameWidthSent'));
              currentStats.videoHeight = Number(result.stat('googFrameHeightSent'));
              currentStats.videoCodec = result.stat('googCodecName');
            } else if (result.stat('googFrameRateReceived')) {
              currentStats.videoRecvBytes = Number(result.stat('bytesReceived'));
              currentStats.videoRecvPackets = Number(result.stat('packetsReceived'));
              currentStats.videoRecvPacketsLost = Number(result.stat('packetsLost'));
              currentStats.videoFrameRate = Number(result.stat('googFrameRateOutput'));
              currentStats.videoWidth = Number(result.stat('googFrameWidthReceived'));
              currentStats.videoHeight = Number(result.stat('googFrameHeightReceived'));
              currentStats.videoCodec = result.stat('googCodecName');
            }
            return null;
          },

          parseAudioStats = function (result) {
            if (result.stat('audioInputLevel')) {
              currentStats.audioSentPackets = Number(result.stat('packetsSent'));
              currentStats.audioSentPacketsLost = Number(result.stat('packetsLost'));
              currentStats.audioSentBytes =  Number(result.stat('bytesSent'));
              currentStats.audioCodec = result.stat('googCodecName');
              currentStats.audioRtt = Number(result.stat('googRtt'));
            } else if (result.stat('audioOutputLevel')) {
              currentStats.audioRecvPackets = Number(result.stat('packetsReceived'));
              currentStats.audioRecvPacketsLost = Number(result.stat('packetsLost'));
              currentStats.audioRecvBytes =  Number(result.stat('bytesReceived'));
              currentStats.audioCodec = result.stat('googCodecName');
            }
          },

          parseStatsReports = function (stats) {
            if (stats.result) {
              var resultList = stats.result();
              for (var resultIndex = 0; resultIndex < resultList.length; resultIndex++) {
                var result = resultList[resultIndex];

                if (result.stat) {

                  if(result.stat('googActiveConnection') === 'true') {
                    currentStats.localCandidateType = result.stat('googLocalCandidateType');
                    currentStats.remoteCandidateType = result.stat('googRemoteCandidateType');
                    currentStats.transportType = result.stat('googTransportType');
                  }

                  parseAudioStats(result);
                  parseVideoStats(result);
                }
              }
            }

            completion(null, currentStats);
          };

      peerConnection.getStats(parseStatsReports);
    }
1038540
@Override
    public ChannelFuture block(
            InetAddress multicastAddress, NetworkInterface networkInterface,
            InetAddress sourceToBlock, ChannelPromise promise) {
        checkJavaVersion();

        if (multicastAddress == null) {
            throw new NullPointerException("multicastAddress");
        }
        if (sourceToBlock == null) {
            throw new NullPointerException("sourceToBlock");
        }

        if (networkInterface == null) {
            throw new NullPointerException("networkInterface");
        }
        synchronized (this) {
            if (memberships != null) {
                List<MembershipKey> keys = memberships.get(multicastAddress);
                for (MembershipKey key: keys) {
                    if (networkInterface.equals(key.networkInterface())) {
                        try {
                            key.block(sourceToBlock);
                        } catch (IOException e) {
                            promise.setFailure(e);
                        }
                    }
                }
            }
        }
        promise.setSuccess();
        return promise;
    }
1291672
private static Media getClosestDpi(DpiType current, Media media)
    {
        final Media mediaDpi = Medias.getWithSuffix(media, current.name().toLowerCase(Locale.ENGLISH));
        final Media closest;
        if (mediaDpi.exists())
        {
            closest = mediaDpi;
        }
        else if (current.ordinal() > 0)
        {
            closest = getClosestDpi(DpiType.values()[current.ordinal() - 1], media);
        }
        else
        {
            closest = media;
        }
        return closest;
    }
1056739
def serving_input_fn(self, hparams):
    """"""
    video_input_frames = tf.placeholder(
        dtype=tf.float32,
        shape=[
            None, hparams.video_num_input_frames, self.frame_width,
            self.frame_height, self.num_channels
        ])

    # TODO(michalski): add support for passing input_action and input_reward.
    return tf.estimator.export.ServingInputReceiver(
        features={"inputs": video_input_frames},
        receiver_tensors=video_input_frames)
357135
function Peer(internalPeer){
  Emitter.Target.call(this,emitter);
  
  this[rooms] = {};
  this[pids] = {};
  this[ip] = internalPeer;
  
  plugins.give('peer',this);
}
501291
@ObjectiveCName("sendAudioWithPeer:withName:withDuration:withDescriptor:")
    public void sendAudio(@NotNull Peer peer, @NotNull String fileName,
                          int duration, @NotNull String descriptor) {
        modules.getMessagesModule().sendAudio(peer, fileName, duration, descriptor);
    }
858559
@Override
    public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) {
        return new AudioMediaSession(payloadType, remote, local, null,null);
    }
1273309
def libvlc_media_list_new(p_instance):
    '''
    '''
    f = _Cfunctions.get('libvlc_media_list_new', None) or \
        _Cfunction('libvlc_media_list_new', ((1,),), class_result(MediaList),
                    ctypes.c_void_p, Instance)
    return f(p_instance)
459117
function dialFSM (peerInfo, protocol, callback) {
    _dial({ peerInfo, protocol, options: { useFSM: true, priority: PRIORITY_HIGH }, callback })
  }
221287
function peerResolved (ip, addressType) {
    // Possible cancelation during DNS lookup.
    if (!socket._connecting) return;

    socket._peer = { address: ip || '127.0.0.1', port: options.port };

    // Generate random bytes used to set randomized socket properties.
    // `crypto.randomBytes` calls OpenSSL `RAND_bytes` to generate the bytes.
    //
    //  * [RAND_bytes](http://www.openssl.org/docs/crypto/RAND_bytes.html).
    //  * [node_crypto.cc](https://github.com/joyent/node/blob/v0.8/src/node_crypto.cc#L4517)
    crypto.randomBytes(4, valid(randomzied));
  }
339472
private Resource getMediaInlineResource(MediaRequest mediaRequest) {
    Resource resource = mediaRequest.getResource();
    if (resource == null) {
      return null;
    }

    // check if resource itself is a nt:file node
    if (JcrBinary.isNtFileOrResource(resource)) {
      return resource;
    }

    // check if child node exists which is a nt:file node
    String refProperty = StringUtils.defaultString(mediaRequest.getRefProperty(), mediaHandlerConfig.getMediaInlineNodeName());
    Resource mediaInlineResource = resource.getChild(refProperty);
    if (JcrBinary.isNtFileOrResource(mediaInlineResource)) {
      return mediaInlineResource;
    }

    // not found
    return null;
  }
430913
function piper(to, cbPiper)
  {
    if(pipes[to]) return cbPiper(pipes[to]);

    // make a new pipe for this peering
    var pipe = pipes[to] = new Pipe('peer');
    pipe.to = to;
    pipe.path = {type:'peer',hn:to};

    // handle any peer delivery through the router
    function peer_send(packet, link, cbSend)
    {
      var router = mesh.index[to];
      if(!router) return cbSend('cannot peer to an unknown router: '+pipe.to);
      if(!router.x) return cbSend('cannot peer yet via this router: '+pipe.to);
      if(!link) return cbSend('requires link');

      // no packet means try to send our keys
      if(!packet)
      {
        Object.keys(mesh.keys).forEach(function(csid){
          if(link.csid && link.csid != csid) return; // if we know the csid, only send that key
          var json = {type:'peer',peer:link.hashname,c:router.x.cid()};
          var body = lob.encode(hashname.intermediates(mesh.keys), hashname.key(csid, mesh.keys));
          var attach = lob.encode({type:'link', csid:csid}, body);
          log.debug('sending peer key to',router.hashname,json,csid);
          router.x.send({json:json,body:attach});
        });
        return;
      }

      // if it's an encrypted channel packet, pass through direct to router
      if(packet.head.length == 0) return router.x.sending(packet);

      // otherwise we're always creating a new peer channel to carry the request
      var json = {type:'peer',peer:link.hashname,c:router.x.cid()};
      var body = lob.encode(packet);
      log.debug('sending peer handshake to',router.hashname,json,body);
      router.x.send({json:json,body:body});
      cbSend();
    }


    pipe.on('send', function(context,a1, a2, a3, a4){
      peer_send.call(context,a1,a2,a3,a4)
    })

    cbPiper(pipe);
  }
383946
function peerInfoFromMa (peer) {
    let p
    // PeerInfo
    if (PeerInfo.isPeerInfo(peer)) {
      p = peer
      // Multiaddr instance (not string)
    } else if (multiaddr.isMultiaddr(peer)) {
      const peerIdB58Str = peer.getPeerId()
      try {
        p = swarm._peerBook.get(peerIdB58Str)
      } catch (err) {
        p = new PeerInfo(PeerId.createFromB58String(peerIdB58Str))
      }
      p.multiaddrs.add(peer)
      // PeerId
    } else if (PeerId.isPeerId(peer)) {
      const peerIdB58Str = peer.toB58String()
      p = swarm._peerBook.has(peerIdB58Str) ? swarm._peerBook.get(peerIdB58Str) : peer
    }

    return p
  }
609383
function Host(options) {
  var me = this;

  // peers and cached peer addresses
  this.peers = {};      // local peers
  this.addresses = {};  // cached addresses of peers located on other hosts

  // pubsub
  this.channels = {};   // keys are the channels, values are arrays with callbacks of subscribers

  // default options
  this.options = {
    reconnectTimeout: 5 * 60 * 1000,  // give up reconnecting after 5 minutes
    reconnectDelay: 1000,             // try reconnecting after one second
    reconnectDecay: 2
  };

  // server properties
  this.server = null;
  this.address = null;
  this.port = null;
  this.connections = {}; // List with open connections, key is the url and value is the connection
  this.timers = {};      // reconnect timers

  /**
   * Send a message from one peer to another
   * @param {string} from   Id of the sending peer
   * @param {string} to     Id of the receiving peer
   * @param {*} message     JSON message
   * @returns {Promise.<null, Error>} Resolves when sent
   */
  this.send = function (from, to, message) {
    // see if the peer lives on the same host
    var peer = me.peers[to];
    if (peer) {
      peer.emit('message', from, message);
      return Promise.resolve(null);
    }

    // find the remote host where the recipient is located
    return me.find(to)
        .then(function (url) {
          var conn = me.connections[url];
          if (conn) {
            var request = {
              method: 'send',
              params: {
                from: from,
                to: to,
                message: message
              }
            };
            // TODO: there is a maximum callstack issue when queuing a lot of notifications
            return conn.request(request) // the send request returns null
            //return conn.notify(request) // the send request returns null
                .catch(function (err) {
                  // FIXME: use a protocol for errors, use error code
                  if (err.toString().indexOf('Error: Peer not found') === 0) {
                    // this peer was deleted. Remove it from cache
                    delete me.addresses[to];
                    throw _peerNotFoundError(to);
                  }
                })
          }
          else {
            throw _peerUnreachable(to, url);
          }
        });
  };

  this.config(options);
}
181948
function shareReplay(bufferSize, windowTime, scheduler) {
    return function (source) { return source.lift(shareReplayOperator(bufferSize, windowTime, scheduler)); };
}
868621
private static Media getMediaDpi(Media media)
    {
        Check.notNull(media);

        final DpiType current = dpi;
        if (current == null || current == DpiType.MDPI)
        {
            return media;
        }
        return getClosestDpi(current, media);
    }