Ejemplo n.º 1
0
static void obs_source_draw_texture(texture_t tex, struct source_frame *frame)
{
    effect_t    effect = obs->video.default_effect;
    bool        yuv    = is_yuv(frame->format);
    const char  *type  = yuv ? "DrawYUV" : "DrawRGB";
    technique_t tech;
    eparam_t    param;

    if (!upload_frame(tex, frame))
        return;

    tech = effect_gettechnique(effect, type);
    technique_begin(tech);
    technique_beginpass(tech, 0);

    if (yuv) {
        param = effect_getparambyname(effect, "yuv_matrix");
        effect_setval(effect, param, frame->yuv_matrix,
                      sizeof(float) * 16);
    }

    param = effect_getparambyname(effect, "diffuse");
    effect_settexture(effect, param, tex);

    gs_draw_sprite(tex, frame->flip ? GS_FLIP_V : 0, 0, 0);

    technique_endpass(tech);
    technique_end(tech);
}
Ejemplo n.º 2
0
/**
 * @brief Handle received frame interrupt
 *
 * This function handles transceiver interrupts for received frames.
 *
 * @param trx_id Transceiver identifier
 */
void handle_rx_end_irq(trx_id_t trx_id)
{
	trx_state[trx_id] = RF_TXPREP;
  #if (defined RF215V1) && ((defined SUPPORT_FSK) || (defined SUPPORT_OQPSK))
	stop_rpc(trx_id);
  #endif

	if (upload_frame(trx_id) == false) {
		return;
	}

#ifdef RX_WHILE_BACKOFF
	if (tx_state[trx_id] == TX_BACKOFF) {
		/* Stop backoff timer */
		stop_tal_timer(trx_id);
		tx_state[trx_id] = TX_DEFER;
		tal_pib[trx_id].NumRxFramesDuringBackoff++;
	}

#endif

#ifdef SUPPORT_MODE_SWITCH
	if (tal_pib[trx_id].ModeSwitchEnabled) {
		if (tal_pib[trx_id].phy.modulation == FSK) {
			uint16_t reg_offset = RF_BASE_ADDR_OFFSET * trx_id;
			if (trx_bit_read(reg_offset + SR_BBC0_FSKPHRRX_MS) ==
					0x01) {
				handle_rx_ms_packet(trx_id);
				return;
			}
		}

		if (tal_state[trx_id] == TAL_NEW_MODE_RECEIVING) {
			/* Restore previous PHY, i.e. CSM */
			/* Stop timer waiting for incoming frame at new mode */
			stop_tal_timer(trx_id);
			set_csm(trx_id);
			tal_state[trx_id] = TAL_IDLE;
		}
	}

#endif

#ifdef PROMISCUOUS_MODE
	if (tal_pib[trx_id].PromiscuousMode) {
		complete_rx_transaction(trx_id);
		return;
	}

#endif /* #ifdef PROMISCUOUS_MODE */

	handle_incoming_frame(trx_id);
}
Ejemplo n.º 3
0
static int
app_run (App * app)
{
  GstVaapiImage *image;
  GstVaapiVideoPool *pool;
  GThread *buffer_thread;
  gsize id;
  int ret = EXIT_FAILURE;

  image = gst_vaapi_image_new (app->display, GST_VIDEO_FORMAT_I420,
      app->parser->width, app->parser->height);

  {
    GstVideoInfo vi;
    gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_ENCODED,
        app->parser->width, app->parser->height);
    pool = gst_vaapi_surface_pool_new_full (app->display, &vi, 0);
  }

  buffer_thread = g_thread_new ("get buffer thread", get_buffer_thread, app);

  while (1) {
    GstVaapiSurfaceProxy *proxy;
    GstVaapiSurface *surface;

    if (!load_frame (app, image))
      break;

    if (!gst_vaapi_image_unmap (image))
      break;

    proxy =
        gst_vaapi_surface_proxy_new_from_pool (GST_VAAPI_SURFACE_POOL (pool));
    if (!proxy) {
      g_warning ("Could not get surface proxy from pool.");
      break;
    }
    surface = gst_vaapi_surface_proxy_get_surface (proxy);
    if (!surface) {
      g_warning ("Could not get surface from proxy.");
      break;
    }

    if (!gst_vaapi_surface_put_image (surface, image)) {
      g_warning ("Could not update surface");
      break;
    }

    if (!upload_frame (app->encoder, proxy)) {
      g_warning ("put frame failed");
      break;
    }

    app->read_frames++;
    id = gst_vaapi_surface_get_id (surface);
    g_debug ("input frame %d, surface id = %" G_GSIZE_FORMAT, app->read_frames,
        id);

    gst_vaapi_surface_proxy_unref (proxy);
  }

  app->input_stopped = TRUE;

  g_thread_join (buffer_thread);

  if (!app->encode_failed && feof (app->parser->fp))
    ret = EXIT_SUCCESS;

  gst_vaapi_video_pool_replace (&pool, NULL);
  gst_vaapi_object_unref (image);
  return ret;
}