int main() { int i; struct picture_t pic; struct encoded_pic_t encoded_pic; errno = 0; if(!camera_init(&pic)) goto error_cam; if(!encoder_init(&pic)){ fprintf(stderr,"failed to initialize encoder\n"); goto error_encoder; } if(!preview_init(&pic)) goto error_preview; if(!output_init(&pic)) goto error_output; if(!encoder_encode_headers(&encoded_pic)) goto error_output; if(!output_write_headers(&encoded_pic)) goto error_output; if(!camera_on()) goto error_cam_on; if(signal(SIGINT, stop_recording) == SIG_ERR){ fprintf(stderr,"signal() failed\n"); goto error_signal; } printf("Press ctrl-c to stop recording...\n"); recording = 1; for(i=0; recording; i++){ if(!camera_get_frame(&pic)) break; gen_osd_info(); osd_print(&pic, osd_string); if((i&7)==0) // i%8==0 preview_display(&pic); if(!encoder_encode_frame(&pic, &encoded_pic)) break; applog_flush(); if(!output_write_frame(&encoded_pic)) break; } printf("\nrecorded %d frames\n", i); error_signal: camera_off(); error_cam_on: output_close(); error_output: preview_close(); error_preview: encoder_close(); error_encoder: camera_close(); error_cam: return 0; }
/* ================ monster_death_use When a monster dies, it fires all of its targets with the current enemy as activator. ================ */ void monster_death_use (edict_t *self) { edict_t *player; int i; self->flags &= ~(FL_FLY|FL_SWIM); self->monsterinfo.aiflags &= AI_GOOD_GUY; // Lazarus: If actor/monster is being used as a camera by a player, // turn camera off for that player for (i=0,player=g_edicts+1; i<maxclients->value; i++, player++) { if(player->client && player->client->spycam == self) camera_off(player); } if (self->item) { Drop_Item (self, self->item); self->item = NULL; } if (self->deathtarget) self->target = self->deathtarget; if (!self->target) return; G_UseTargets (self, self->enemy); }
int camera_action(){ switch(a->action){ case ACT_SLAVE:break; default: camera_on(); } switch(a->action){ case ACT_35:camera_vshot(a->focal,a->height,a->width,a->overlap,36,24);break; case ACT_6x45:camera_vshot(a->focal,a->height,a->width,a->overlap,45,60);break; case ACT_45x6:camera_vshot(a->focal,a->height,a->width,a->overlap,60,45);break; case ACT_6x6:camera_vshot(a->focal,a->height,a->width,a->overlap,60,60);break; case ACT_6x7:camera_vshot(a->focal,a->height,a->width,a->overlap,70,60);break; case ACT_7x6:camera_vshot(a->focal,a->height,a->width,a->overlap,60,70);break; case ACT_6x8:camera_vshot(a->focal,a->height,a->width,a->overlap,80,60);break; case ACT_8x6:camera_vshot(a->focal,a->height,a->width,a->overlap,60,80);break; case ACT_6x9:camera_vshot(a->focal,a->height,a->width,a->overlap,90,60);break; case ACT_9x6:camera_vshot(a->focal,a->height,a->width,a->overlap,60,90);break; case ACT_6x17:camera_vshot(a->focal,a->height,a->width,a->overlap,170,60);break; case ACT_17x6:camera_vshot(a->focal,a->height,a->width,a->overlap,60,170);break; case ACT_TEST:camera_test();break; case ACT_SLAVE:slave_read();break; case ACT_VIRTUAL:camera_vshot(a->focal,a->height,a->width,a->overlap,a->vheight,a->vwidth);break; case ACT_SPHERE:camera_sphere(a->focal,a->height,a->width,a->overlap);break; case ACT_XXX:warning("Not Implemented yet");break; } switch(a->action){ case ACT_SLAVE:break; default: camera_off(); } }
void camTrack_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) { edict_t *player; edict_t *nextTarget; if (!plane) return; player = &g_edicts[1]; // Gotta be, since this is SP only //delete bullet model. G_FreeEdict(self->child); //hit wall. //if no next target, then abort. if (!self->owner->target) { camera_off(player); //fire targets. FireTarget2(self->owner); return; } //fire targets. FireTarget2(self->owner); nextTarget = G_Find(NULL,FOFS(targetname), self->owner->target); if (!nextTarget) { camera_off(player); return; } FirePathTarget(nextTarget); WarpToNextPoint(self, nextTarget); }
void use_camshoot(edict_t *self, edict_t *other, edict_t *activator) { edict_t *player; edict_t *target; player = &g_edicts[1]; // Gotta be, since this is SP only if(!player->client) return; if(player->client->spycam) // already using camera return; target = camTrack(self); if(!target) return; target->owner = self; player->client->ps.stats[STAT_USEABLE] = 0; player->client->ps.stats[STAT_HINTTITLE] = 1; VectorClear (player->velocity); if (!(self->spawnflags & 1)) { target->child = CreateCamBullet(target, self); } player->client->spycam = target; player->client->monitor = self; camera_on(player); //player->client->ps.pmove.pm_time = 160>>3; // hold time //player->client->ps.pmove.pm_flags |= PMF_TIME_TELEPORT; if (self->spawnflags & 1) { //skip the bulletcam, go straight to the tracks. edict_t *nextTarget; nextTarget = NULL; nextTarget = G_Find(NULL,FOFS(targetname), self->target); if (!nextTarget) { camera_off(player); return; } FirePathTarget(nextTarget); WarpToNextPoint(target, nextTarget); } }
void DeactivateCam(edict_t *self) { edict_t *player; player = &g_edicts[1]; // Gotta be, since this is SP only camera_off(player); }
int main() { int s32MainFd,temp; struct timespec ts = { 2, 0 }; //================================================= ringmalloc(640*480); errno = 0; if(!camera_init(&pic)) goto error_cam; if(!encoder_init(&pic)) goto error_encoder; if(!preview_init(&pic)) goto error_preview; get_filename(); printf("file:%s\n",mkv_filename); if(!output_init(&pic,mkv_filename)) goto error_output; if(!encoder_encode_headers(&encoded_pic)) goto error_output; memcpy(&header_pic,&encoded_pic,sizeof(encoded_pic)); header_pic.buffer=malloc(encoded_pic.length); memcpy(header_pic.buffer,encoded_pic.buffer,encoded_pic.length); if(!output_write_headers(&encoded_pic,&psp)) goto error_output; encoder_release(&encoded_pic); if(!camera_on()) goto error_cam_on; //================================================ printf("RTSP server START\n"); PrefsInit(); printf("listen for client connecting...\n"); signal(SIGINT, IntHandl); s32MainFd = tcp_listen(SERVER_RTSP_PORT_DEFAULT); /* 初始化schedule_list 队列,创建调度线程,参考 schedule.c */ if (ScheduleInit(&pic,&encoded_pic) == ERR_FATAL) { fprintf(stderr,"Fatal: Can't start scheduler %s, %i \nServer is aborting.\n", __FILE__, __LINE__); return 0; } /* 将所有可用的RTP端口号放入到port_pool[MAX_SESSION] 中 */ RTP_port_pool_init(RTP_DEFAULT_PORT); //循环等待 if((temp = pthread_create(&thread[0], NULL, cam_thread, NULL)) != 0) printf("cam_thread error!\n"); else printf("cam_thread ok\n"); pthread_mutex_init(&mut,NULL); while (!g_s32Quit) { nanosleep(&ts, NULL); /*查找收到的rtsp连接, * 对每一个连接产生所有的信息放入到结构体rtsp_list中 */ // trace_point(); EventLoop(s32MainFd); } ringfree(); printf("The Server quit!\n"); camera_off(); error_cam_on: output_close(); error_output: preview_close(); error_preview: encoder_close(); error_encoder: camera_close(); error_cam: return NULL; }