int main(int argc, char** argv) #endif { struct arg_arr* aarr; struct arcan_shmif_cont cont = arcan_shmif_open( SEGID_APPLICATION, SHMIF_ACQUIRE_FATALFAIL, &aarr); arcan_event ev; bool running = true; arcan_shmif_resize(&cont, 640, 480); uint8_t step_r = 0; uint8_t step_g = 0; uint8_t step_b = 255; int frames = 0; while(running){ if (frames++ > 200){ printf("send resize\n"); arcan_shmif_resize(&cont, 128 + (rand() % 1024), 128 + (rand() % 1024)); printf("unlock resize\n"); frames = 0; } printf("frame(%zu, %zu)\n", cont.w, cont.h); for (size_t row = 0; row < cont.h; row++) for (size_t col = 0; col < cont.w; col++){ cont.vidp[ row * cont.addr->w + col ] = SHMIF_RGBA(step_r, step_g, step_b, 0xff); step_r++; step_g += step_r == 255; step_b += step_g == 255; } arcan_shmif_signal(&cont, SHMIF_SIGVID); int rv; while ( (rv = arcan_shmif_poll(&cont, &ev)) == 1){ if (ev.category == EVENT_TARGET) switch (ev.tgt.kind){ case TARGET_COMMAND_EXIT: running = false; break; default: break; } } } #ifndef ENABLE_FSRV_AVFEED return EXIT_SUCCESS; #endif }
/* * Quick skeleton to map up a audio/video/input * source to an arcan frameserver along with some helpers. */ int afsrv_avfeed(struct arcan_shmif_cont* con, struct arg_arr* args) { if (!con){ dump_help(); return EXIT_FAILURE; } struct arcan_shmif_cont shms = *con; if (!arcan_shmif_resize(&shms, 320, 200)){ LOG("arcan_frameserver(decode) shmpage setup, resize failed\n"); return EXIT_FAILURE; } update_frame(&shms, RGBA(0xff, 0xff, 0xff, 0xff)); arcan_event ev; while(1) while(arcan_shmif_wait(&shms, &ev)){ if (ev.category == EVENT_TARGET){ if (ev.tgt.kind == TARGET_COMMAND_EXIT){ fprintf(stdout, "parent requested termination, leaving.\n"); return EXIT_SUCCESS; } else { static int red; update_frame(&shms, RGBA(red++, 0x00, 0x00, 0xff)); } } } return EXIT_FAILURE; }
int main(int argc, char** argv) { struct arg_arr* aarr; struct arcan_shmif_cont cont = arcan_shmif_open( SEGID_APPLICATION, SHMIF_ACQUIRE_FATALFAIL, &aarr); arcan_event ev; bool running = true; arcan_shmif_resize(&cont, 320, 200); /* fill with red and transfer */ for (size_t row = 0; row < cont.addr->h; row++) for (size_t col = 0; col < cont.addr->w; col++) cont.vidp[ row * cont.addr->w + col ] = RGBA(255, 0, 0, 255); arcan_shmif_signal(&cont, SHMIF_SIGVID); while (running && arcan_shmif_wait(&cont, &ev)){ if (ev.category == EVENT_TARGET) switch (ev.tgt.kind){ case TARGET_COMMAND_EXIT: running = false; default: break; } } return EXIT_SUCCESS; }
static void dispatch_event(arcan_event* ev, struct rwstat_ch* ch, struct senseye_priv* chp) { if (rwstat_consume_event(ch, ev)) return; if (ev->category == EVENT_TARGET) switch (ev->tgt.kind){ case TARGET_COMMAND_REQFAIL: chp->running = false; break; case TARGET_COMMAND_PAUSE: chp->paused = true; break; case TARGET_COMMAND_DISPLAYHINT:{ size_t base = ev->tgt.ioevs[0].iv; if (base > 0 && (base & (base - 1)) == 0 && arcan_shmif_resize(&chp->cont, base, base)) ch->resize(ch, base); else FLOG("Senseye:FDsense: bad displayhint: %d\n", ev->tgt.ioevs[0].iv); } /* resize buffer to new base */ break; case TARGET_COMMAND_UNPAUSE: chp->paused = false; break; case TARGET_COMMAND_STEPFRAME: chp->framecount = ev->tgt.ioevs[0].iv; break; case TARGET_COMMAND_EXIT: chp->running = false; break; default: #ifdef _DEBUG printf("unhandled event : %s\n", arcan_shmif_eventstr(ev, NULL, 0)); #endif break; } }
static void wayland_drm_commit(struct comp_surf* surf, struct wl_drm_buffer* buf, struct arcan_shmif_cont* con) { if (buf->width != con->w || buf->height != con->h){ arcan_shmif_resize(con, buf->width, buf->height); } /* * The patches for the multi- buffer formats are coming in, but are not yet * here - basically in this layer it should only be setting a flag on the * SHMIF_SIGNAL to indicate a continuation, and repeat for all buffers */ arcan_shmif_signalhandle(con, SHMIF_SIGVID, buf->fd, buf->stride[0], buf->format); /* * [ actually happens inside signalhandle ] * close(buf->fd); buf->fd = -1; */ }