static GstFlowReturn
gst_rfb_src_fill (GstPushSrc * psrc, GstBuffer * outbuf)
{
  GstRfbSrc *src = GST_RFB_SRC (psrc);
  RfbDecoder *decoder = src->decoder;
  GstMapInfo info;

  rfb_decoder_send_update_request (decoder, src->incremental_update,
      decoder->offset_x, decoder->offset_y, decoder->rect_width,
      decoder->rect_height);

  while (decoder->state != NULL) {
    if (!rfb_decoder_iterate (decoder)) {
      if (decoder->error != NULL) {
        GST_ELEMENT_ERROR (src, RESOURCE, READ,
            ("Error on VNC connection to host %s on port %d: %s",
                src->host, src->port, decoder->error->message), (NULL));
      } else {
        GST_ELEMENT_ERROR (src, RESOURCE, READ,
            ("Error on setup VNC connection to host %s on port %d", src->host,
                src->port), (NULL));
      }
      return GST_FLOW_ERROR;
    }
  }

  if (!gst_buffer_map (outbuf, &info, GST_MAP_WRITE)) {
    GST_ELEMENT_ERROR (src, RESOURCE, WRITE,
        ("Could not map the output frame"), (NULL));
    return GST_FLOW_ERROR;
  }

  memcpy (info.data, decoder->frame, info.size);

  GST_BUFFER_PTS (outbuf) =
      gst_clock_get_time (GST_ELEMENT_CLOCK (src)) -
      GST_ELEMENT_CAST (src)->base_time;

  gst_buffer_unmap (outbuf, &info);

  return GST_FLOW_OK;
}
예제 #2
0
int
main (int argc, char *argv[])
{
  RfbDecoder *decoder;

  // int fd = 0;

  decoder = rfb_decoder_new ();

  rfb_decoder_connect_tcp (decoder, "127.0.0.1", 5901);
  // rfb_decoder_use_file_descriptor (decoder, fd);

  while (!decoder->inited)
    rfb_decoder_iterate (decoder);

  rfb_decoder_send_update_request (decoder, FALSE, 0, 0, 100, 100);

  while (1) {
    rfb_decoder_iterate (decoder);
  }

  return 0;
}