示例#1
0
int
video_source_setup(const char *pipeformat, int channel_id, int maxwidth, int maxheight, int maxstride) {
	vsource_config config;
	bzero(&config, sizeof(config));
	config.rtp_id = channel_id;
	config.maxwidth = maxwidth;
	config.maxheight = maxheight;
	config.maxstride = maxstride;
	return video_source_setup_ex(pipeformat, &config, 1);
}
示例#2
0
static int
vencoder_init(void *arg) {
	int iid, width, height, fps, bitrate, gopsize;
	int vsmode[3];
	char *pipefmt = (char*) arg;
	struct RTSPConf *rtspconf = rtspconf_global();
	omx_streamer_config_t sc;
	//
	if(rtspconf == NULL) {
		sb_error("video encoder: no configuration found\n");
		return -1;
	}
	if(vencoder_initialized != 0)
		return 0;
	//
	iid = 0;
	//
	if(sb_conf_readints("video-source-v4l-mode", vsmode, 3) == 3) {
		sb_error("video encoder: use user config: %d %d %d\n",
				vsmode[0], vsmode[1], vsmode[2]);
		width = vsmode[1];
		height = vsmode[2];
	} else {
		width = 640;
		height = 480;
	}
	if((fps = sb_conf_readint("video-fps")) <= 1) {
		fps = 24;
	}
	if((bitrate = sb_conf_mapreadint("video-specific", "b")) < 1000000) {
		bitrate = 3000000;
	}
	if((gopsize = sb_conf_mapreadint("video-specific", "g")) < 5) {
		gopsize = fps;
	}
	// search for photo seq
	if(init_image_storage() < 0) {
		return -1;
	}
	// register a dummy video source: only once
	if(vsource_initialized == 0) {
		vsource_config_t config;
		bzero(&config, sizeof(config));
		config.curr_width = width;
		config.curr_height = height;
		config.curr_stride = width;
		if(video_source_setup_ex(&config, 1) < 0) {
			sb_error("video encoder: setup dummy source failed (%dx%d)\n", width, height);
			return -1;
		}
		sb_error("video encoder: dummy source configured (%dx%d)\n", width, height);
		vsource_initialized = 1;
	}
	//
	sb_error("video encoder: mode=(ignored) (%dx%d), fps=%d\n",
		width, height, fps);
	// load configs
	bzero(&sc, sizeof(sc));
	sc.camera_sharpness = sb_omx_load_int("omx-camera-sharpness", -100, 100, OSCAM_DEF_SHARPNESS);
	sc.camera_contrast = sb_omx_load_int("omx-camera-contrast", -100, 100, OSCAM_DEF_CONTRAST);
	sc.camera_brightness = sb_omx_load_int("omx-camera-brightness", 0, 100, OSCAM_DEF_BRIGHTNESS);
	sc.camera_saturation = sb_omx_load_int("omx-camera-saturation", -100, 100, OSCAM_DEF_SATURATION);
	sc.camera_ev = sb_omx_load_int("omx-camera-ev", -10, 10, OSCAM_DEF_EXPOSURE_VALUE_COMPENSATION);
	sc.camera_iso = sb_omx_load_int("omx-camera-iso", 100, 800, OSCAM_DEF_EXPOSURE_ISO_SENSITIVITY);
	sc.camera_iso_auto = sb_omx_load_bool("omx-camera-iso-auto", OSCAM_DEF_EXPOSURE_AUTO_SENSITIVITY);
	sc.camera_frame_stabilisation = sb_omx_load_bool("omx-camera-frame-stabilisation", OSCAM_DEF_FRAME_STABILISATION);
	sc.camera_flip_horizon = sb_omx_load_bool("omx-camera-flip-horizon", OSCAM_DEF_FLIP_HORIZONTAL);
	sc.camera_flip_vertical = sb_omx_load_bool("omx-camera-flip-vertical", OSCAM_DEF_FLIP_VERTICAL);
	sc.camera_whitebalance =
		(enum OMX_WHITEBALCONTROLTYPE) sb_omx_load_int("camera-omx-whitebalance", 0, (int) OMX_WhiteBalControlMax, (int) OSCAM_DEF_WHITE_BALANCE_CONTROL);
	sc.camera_filter =
		(enum OMX_IMAGEFILTERTYPE) sb_omx_load_int("camera-omx-filter", (int) OMX_ImageFilterNone, (int) OMX_ImageFilterMax, (int) OSCAM_DEF_IMAGE_FILTER);
	//
	if(omx_streamer_init(&omxe[iid], NULL, width, height, fps, 1, bitrate, gopsize) < 0) {
		sb_error("video encoder: init failed.\n");
		return -1;
	}
	// register a dummy control
	ctrl_server_setreplay(camera_control);
	sb_error("video encoder: dummy control enabled.\n");
	//
	vencoder_initialized = 1;
	sb_error("video encoder: initialized (%d channels).\n", iid+1);
	return 0;
init_failed:
	vencoder_deinit(NULL);
	return -1;
}