Resize the rendering and start sending video over TCP.
13822
public void start(MissionInit missionInit, IVideoProducer videoProducer, VideoProducedObserver observer, MalmoEnvServer envServer)
    {
        if (videoProducer == null)
        {
            return; // Don't start up if there is nothing to provide the video.
        }

        videoProducer.prepare(missionInit);
        this.missionInit = missionInit;
        this.videoProducer = videoProducer;
        this.observer = observer;
        this.envServer = envServer;
        this.buffer = BufferUtils.createByteBuffer(this.videoProducer.getRequiredBufferSize());
        this.headerbuffer = ByteBuffer.allocate(20).order(ByteOrder.BIG_ENDIAN);
        this.renderWidth = videoProducer.getWidth();
        this.renderHeight = videoProducer.getHeight();
        resizeIfNeeded();
        Display.setResizable(false); // prevent the user from resizing using the window borders

        ClientAgentConnection cac = missionInit.getClientAgentConnection();
        if (cac == null)
            return;	// Don't start up if we don't have any connection details.

        String agentIPAddress = cac.getAgentIPAddress();
        int agentPort = 0;
        switch (videoProducer.getVideoType())
        {
        case LUMINANCE:
            agentPort = cac.getAgentLuminancePort();
            break;
        case DEPTH_MAP:
            agentPort = cac.getAgentDepthPort();
            break;
        case VIDEO:
            agentPort = cac.getAgentVideoPort();
            break;
        case COLOUR_MAP:
            agentPort = cac.getAgentColourMapPort();
            break;
        }

        this.connection = new TCPSocketChannel(agentIPAddress, agentPort, "vid");
        this.failedTCPSendCount = 0;

        try
        {
            MinecraftForge.EVENT_BUS.register(this);
        }
        catch(Exception e)
        {
            System.out.println("Failed to register video hook: " + e);
        }
        this.isRunning = true;
    }
604260
def __SendChunk(self, start, additional_headers=None):
        """"""
        self.EnsureInitialized()
        no_log_body = self.total_size is None
        request = http_wrapper.Request(url=self.url, http_method='PUT')
        if self.__gzip_encoded:
            request.headers['Content-Encoding'] = 'gzip'
            body_stream, read_length, exhausted = compression.CompressStream(
                self.stream, self.chunksize)
            end = start + read_length
            # If the stream length was previously unknown and the input stream
            # is exhausted, then we're at the end of the stream.
            if self.total_size is None and exhausted:
                self.__total_size = end
        elif self.total_size is None:
            # For the streaming resumable case, we need to detect when
            # we're at the end of the stream.
            body_stream = buffered_stream.BufferedStream(
                self.stream, start, self.chunksize)
            end = body_stream.stream_end_position
            if body_stream.stream_exhausted:
                self.__total_size = end
            # TODO: Here, change body_stream from a stream to a string object,
            # which means reading a chunk into memory.  This works around
            # https://code.google.com/p/httplib2/issues/detail?id=176 which can
            # cause httplib2 to skip bytes on 401's for file objects.
            # Rework this solution to be more general.
            body_stream = body_stream.read(self.chunksize)
        else:
            end = min(start + self.chunksize, self.total_size)
            body_stream = stream_slice.StreamSlice(self.stream, end - start)
        # TODO(craigcitro): Think about clearer errors on "no data in
        # stream".
        request.body = body_stream
        request.headers['Content-Type'] = self.mime_type
        if no_log_body:
            # Disable logging of streaming body.
            # TODO: Remove no_log_body and rework as part of a larger logs
            # refactor.
            request.loggable_body = '<media body>'
        if self.total_size is None:
            # Streaming resumable upload case, unknown total size.
            range_string = 'bytes %s-%s/*' % (start, end - 1)
        elif end == start:
            # End of an upload with 0 bytes left to send; just finalize.
            range_string = 'bytes */%s' % self.total_size
        else:
            # Normal resumable upload case with known sizes.
            range_string = 'bytes %s-%s/%s' % (start, end - 1, self.total_size)

        request.headers['Content-Range'] = range_string
        if additional_headers:
            request.headers.update(additional_headers)

        return self.__SendMediaRequest(request, end)
1242410
def sendRtspRequest(self, requestCode):
    """"""
    #-------------
    # TO COMPLETE
    #-------------

    # Setup request
    if requestCode == self.SETUP and self.state == self.INIT:
      threading.Thread(target=self.recvRtspReply).start()
      # Update RTSP sequence number.
      # ...
      self.rtspSeq = 1

      # Write the RTSP request to be sent.
      # request = ...
      request = "SETUP " + str(self.fileName) + "\n" + str(self.rtspSeq) + "\n" + " RTSP/1.0 RTP/UDP " + str(self.rtpPort)

      self.rtspSocket.send(request)
      # Keep track of the sent request.
      # self.requestSent = ...
      self.requestSent = self.SETUP

    # Play request
    elif requestCode == self.PLAY and self.state == self.READY:
      # Update RTSP sequence number.
      # ...
      self.rtspSeq = self.rtspSeq + 1
      # Write the RTSP request to be sent.
      # request = ...
      request = "PLAY " + "\n" + str(self.rtspSeq)

      self.rtspSocket.send(request)
      print('-'*60 + "\nPLAY request sent to Server...\n" + '-'*60)
      # Keep track of the sent request.
      # self.requestSent = ...
      self.requestSent = self.PLAY

    # Pause request
    elif requestCode == self.PAUSE and self.state == self.PLAYING:
      # Update RTSP sequence number.
      # ...
      self.rtspSeq = self.rtspSeq + 1
      # Write the RTSP request to be sent.
      # request = ...
      request = "PAUSE " + "\n" + str(self.rtspSeq)
      self.rtspSocket.send(request)
      print('-'*60 + "\nPAUSE request sent to Server...\n" + '-'*60)
      # Keep track of the sent request.
      # self.requestSent = ...
      self.requestSent = self.PAUSE

    # Resume request


    # Teardown request
    elif requestCode == self.TEARDOWN and not self.state == self.INIT:
      # Update RTSP sequence number.
      # ...
      self.rtspSeq = self.rtspSeq + 1
      # Write the RTSP request to be sent.
      # request = ...
      request = "TEARDOWN " + "\n" + str(self.rtspSeq)
      self.rtspSocket.send(request)
      print('-'*60 + "\nTEARDOWN request sent to Server...\n" + '-'*60)
      # Keep track of the sent request.
      # self.requestSent = ...
      self.requestSent = self.TEARDOWN

    else:
      return
972257
function resize(w, h) {
         this._super(me.Renderable, "resize", [this.repeatX ? Infinity : w, this.repeatY ? Infinity : h]);
       }
344605
final void recycleVideoBuffer(BaseVideoFrame frame) {
		// Make sure we are in started state
		if (state.isStarted())
		{
			enqueueBuffer(object, frame.getBufferInex());

			synchronized(availableVideoFrames){
				availableVideoFrames.add(frame);
				availableVideoFrames.notify();
			}
		}
	}
76450
function(){
                res.type('.html');
                res.send(_render(tpl, css, {
                    code: httpStatusCode,
                    title: pageData.title,
                    message: pageData.message,
                    footer: opt.footer
                }))
            }
1296131
function broadcast() {
        scope.broadcast('resize', {
            // shortcuts for offsetWidth/height
            width: currentOffsetWidth,
            height: currentOffsetHeight,
            // client width is width of the inner, visible area
            clientWidth: currentClientWidth,
            clientHeight: currentClientHeight,
            // offset width is the width of the element, including border,
            // padding, and scrollbars
            offsetWidth: currentOffsetWidth,
            offsetHeight: currentOffsetHeight
        });
    }
554389
def pre_render(self):
        """"""
        self.add_styles()
        self.add_scripts()
        self.root.set(
            'viewBox', '0 0 %d %d' % (self.graph.width, self.graph.height)
        )
        if self.graph.explicit_size:
            self.root.set('width', str(self.graph.width))
            self.root.set('height', str(self.graph.height))
929099
def push(self):
        
        if self.comm is None:
            raise Exception('Renderer does not have a comm.')
        diff = self.renderer.diff(self)
        self.comm.send(diff)
720124
def render_thread(self):
    """"""
    obs = True
    while obs:  # Send something falsy through the queue to shut down.
      obs = self._obs_queue.get()
      if obs:
        for alert in obs.observation.alerts:
          self._alerts[sc_pb.Alert.Name(alert)] = time.time()
        for err in obs.action_errors:
          if err.result != sc_err.Success:
            self._alerts[sc_err.ActionResult.Name(err.result)] = time.time()
        self.prepare_actions(obs)
        if self._obs_queue.empty():
          # Only render the latest observation so we keep up with the game.
          self.render_obs(obs)
        if self._video_writer:
          self._video_writer.add(np.transpose(
              pygame.surfarray.pixels3d(self._window), axes=(1, 0, 2)))
      self._obs_queue.task_done()
246058
def render(self):
        
        self.screen.reset()
        self.screen.blit(self.corners)
        self.screen.blit(self.lines, (1, 1))
        self.screen.blit(self.rects, (int(self.screen.width / 2) + 1, 1))
        self.screen.blit(self.circle, (0, int(self.screen.height / 2) + 1))
        self.screen.blit(self.filled, (int(self.screen.width / 2) + 1,
                                       int(self.screen.height / 2) + 1))

        self.screen.update()
        self.clock.tick()
309247
def _send_size(self):
        "  "
        rows, cols = _get_size(sys.stdout.fileno())
        self._send_packet({
            'cmd': 'size',
            'data': [rows, cols]
        })
1170516
def parseRtspReply(self, data):
    print("Parsing Received Rtsp data...")

    """"""
    lines = data.split('\n')
    seqNum = int(lines[1].split(' ')[1])

    # Process only if the server reply's sequence number is the same as the request's
    if seqNum == self.rtspSeq:
      session = int(lines[2].split(' ')[1])
      # New RTSP session ID
      if self.sessionId == 0:
        self.sessionId = session

      # Process only if the session ID is the same
      if self.sessionId == session:
        if int(lines[0].split(' ')[1]) == 200:
          if self.requestSent == self.SETUP:
            #-------------
            # TO COMPLETE
            #-------------
            # Update RTSP state.
            print("Updating RTSP state...")
            # self.state = ...
            self.state = self.READY
            # Open RTP port.
            #self.openRtpPort()
            print("Setting Up RtpPort for Video Stream")
            self.openRtpPort()

          elif self.requestSent == self.PLAY:
             self.state = self.PLAYING
             print('-'*60 + "\nClient is PLAYING...\n" + '-'*60)
          elif self.requestSent == self.PAUSE:
             self.state = self.READY

            # The play thread exits. A new thread is created on resume.
             self.playEvent.set()

          elif self.requestSent == self.TEARDOWN:
            # self.state = ...

            # Flag the teardownAcked to close the socket.
            self.teardownAcked = 1
874387
def send(self, sender: PytgbotApiBot):
        
        return sender.send_video(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            video=self.video, chat_id=self.receiver, reply_to_message_id=self.reply_id, duration=self.duration, width=self.width, height=self.height, thumb=self.thumb, caption=self.caption, parse_mode=self.parse_mode, supports_streaming=self.supports_streaming, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )
1275620
function _oldStyleShareReplay (bufferSize, windowTime, scheduler) {
  let subject;

  const connectable = multicast(function shareReplaySubjectFactory () {
    if (this._isComplete) {
      return subject;
    } else {
      return (subject = new ReplaySubject(bufferSize, windowTime, scheduler));
    }
  });
  return (source) => refCount()(connectable(source));
}
513530
def _setup_transport(self):
        
        self._write = self.sock.sendall
        self._read_buffer = bytes()
267062
def openRtpPort(self):
    """"""
    #-------------
    # TO COMPLETE
    #-------------
    # Create a new datagram socket to receive RTP packets from the server
    # self.rtpSocket = ...


    # Set the timeout value of the socket to 0.5sec
    # ...
    self.rtpSocket.settimeout(0.5)
#   try:
      # Bind the socket to the address using the RTP port given by the client user
      # ...
#   except:
#     tkMessageBox.showwarning('Unable to Bind', 'Unable to bind PORT=%d' %self.rtpPort)

    try:
      #self.rtpSocket.connect(self.serverAddr,self.rtpPort)
      self.rtpSocket.bind((self.serverAddr,self.rtpPort))   # WATCH OUT THE ADDRESS FORMAT!!!!!  rtpPort# should be bigger than 1024
      #self.rtpSocket.listen(5)
      print "Bind RtpPort Success"

    except:
      tkMessageBox.showwarning('Connection Failed', 'Connection to rtpServer failed...')