Beispiel #1
0
void moCameraModule::start() {
	assert( this->camera == NULL );
	LOGM(MO_TRACE, "start camera");

	this->camera = cvCaptureFromCAM(this->property("index").asInteger());
	if ( this->camera == NULL ) {
		LOGM(MO_ERROR, "could not load camera: " << this->property("index").asInteger());
		this->setError("Unable to open camera");
	}
	moModule::start();
}
static int _rmnet_vnd_do_qos_ioctl(struct net_device *dev,
				   struct ifreq *ifr,
				   int cmd)
{
	struct rmnet_vnd_private_s *dev_conf;
	int rc;
	rc = 0;
	dev_conf = (struct rmnet_vnd_private_s *) netdev_priv(dev);

	switch (cmd) {

	case RMNET_IOCTL_SET_QOS_ENABLE:
		LOGM("%s(): RMNET_IOCTL_SET_QOS_ENABLE on %s\n",
		     __func__, dev->name);
		dev_conf->qos_mode = 1;
		break;

	case RMNET_IOCTL_SET_QOS_DISABLE:
		LOGM("%s(): RMNET_IOCTL_SET_QOS_DISABLE on %s\n",
		     __func__, dev->name);
		dev_conf->qos_mode = 0;
		break;

	case RMNET_IOCTL_FLOW_ENABLE:
		LOGL("%s(): RMNET_IOCTL_FLOW_ENABLE on %s\n",
		     __func__, dev->name);
		tc_qdisc_flow_control(dev, (u32)ifr->ifr_data, 1);
		break;

	case RMNET_IOCTL_FLOW_DISABLE:
		LOGL("%s(): RMNET_IOCTL_FLOW_DISABLE on %s\n",
		     __func__, dev->name);
		tc_qdisc_flow_control(dev, (u32)ifr->ifr_data, 0);
		break;

	case RMNET_IOCTL_GET_QOS:           
		LOGM("%s(): RMNET_IOCTL_GET_QOS on %s\n",
		     __func__, dev->name);
		ifr->ifr_ifru.ifru_data =
			(void *)(dev_conf->qos_mode == 1);
		break;

	default:
		rc = -EINVAL;
	}

	return rc;
}
static int rmnet_vnd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
	struct rmnet_vnd_private_s *dev_conf;
	int rc;
	rc = 0;
	dev_conf = (struct rmnet_vnd_private_s *) netdev_priv(dev);

	rc = _rmnet_vnd_do_qos_ioctl(dev, ifr, cmd);
	if (rc != -EINVAL)
		return rc;
	rc = 0; 

	switch (cmd) {

	case RMNET_IOCTL_OPEN: 
		LOGM("%s(): RMNET_IOCTL_OPEN on %s (ignored)\n",
		     __func__, dev->name);
		break;

	case RMNET_IOCTL_CLOSE: 
		LOGM("%s(): RMNET_IOCTL_CLOSE on %s (ignored)\n",
		     __func__, dev->name);
		break;

	case RMNET_IOCTL_SET_LLP_ETHERNET:
		LOGM("%s(): RMNET_IOCTL_SET_LLP_ETHERNET on %s (no support)\n",
		     __func__, dev->name);
		rc = -EINVAL;
		break;

	case RMNET_IOCTL_SET_LLP_IP: 
		LOGM("%s(): RMNET_IOCTL_SET_LLP_IP on %s  (ignored)\n",
		     __func__, dev->name);
		break;

	case RMNET_IOCTL_GET_LLP: 
		LOGM("%s(): RMNET_IOCTL_GET_LLP on %s\n",
		     __func__, dev->name);
		ifr->ifr_ifru.ifru_data = (void *)(RMNET_MODE_LLP_IP);
		break;

	default:
		LOGH("%s(): Unkown IOCTL 0x%08X\n", __func__, cmd);
		rc = -EINVAL;
	}

	return rc;
}
Beispiel #4
0
static int APP_CC
setup_listen(void)
{
    char port[256];
    int error = 0;

    if (g_lis_trans != 0)
    {
        trans_delete(g_lis_trans);
    }

    if (g_use_unix_socket)
    {
        g_lis_trans = trans_create(2, 8192, 8192);
        g_snprintf(port, 255, "/tmp/.xrdp/xrdp_chansrv_socket_%d",
                   7200 + g_display_num);
    }
    else
    {
        g_lis_trans = trans_create(1, 8192, 8192);
        g_snprintf(port, 255, "%d", 7200 + g_display_num);
    }

    g_lis_trans->trans_conn_in = my_trans_conn_in;
    error = trans_listen(g_lis_trans, port);

    if (error != 0)
    {
        LOGM((LOG_LEVEL_ERROR, "setup_listen: trans_listen failed for port %s",
              port));
        return 1;
    }

    return 0;
}
Beispiel #5
0
int DEFAULT_CC
my_trans_conn_in(struct trans *trans, struct trans *new_trans)
{
    if (trans == 0)
    {
        return 1;
    }

    if (trans != g_lis_trans)
    {
        return 1;
    }

    if (g_con_trans != 0) /* if already set, error */
    {
        return 1;
    }

    if (new_trans == 0)
    {
        return 1;
    }

    LOGM((LOG_LEVEL_DEBUG, "my_trans_conn_in:"));
    g_con_trans = new_trans;
    g_con_trans->trans_data_in = my_trans_data_in;
    g_con_trans->header_size = 8;
    /* stop listening */
    trans_delete(g_lis_trans);
    g_lis_trans = 0;
    return 0;
}
Beispiel #6
0
/* returns error */
int DEFAULT_CC
my_trans_data_in(struct trans *trans)
{
    struct stream *s = (struct stream *)NULL;
    int id = 0;
    int size = 0;
    int error = 0;

    if (trans == 0)
    {
        return 0;
    }

    if (trans != g_con_trans)
    {
        return 1;
    }

    LOGM((LOG_LEVEL_DEBUG, "my_trans_data_in:"));
    s = trans_get_in_s(trans);
    in_uint32_le(s, id);
    in_uint32_le(s, size);
    error = trans_force_read(trans, size - 8);

    if (error == 0)
    {
        /* here, the entire message block is read in, process it */
        error = process_message();
    }

    return error;
}
Beispiel #7
0
/* returns error */
static int APP_CC
process_message(void)
{
    struct stream *s = (struct stream *)NULL;
    int size = 0;
    int id = 0;
    int rv = 0;
    char *next_msg = (char *)NULL;

    if (g_con_trans == 0)
    {
        return 1;
    }

    s = trans_get_in_s(g_con_trans);

    if (s == 0)
    {
        return 1;
    }

    rv = 0;

    while (s_check_rem(s, 8))
    {
        next_msg = s->p;
        in_uint32_le(s, id);
        in_uint32_le(s, size);
        next_msg += size;

        switch (id)
        {
            case 1: /* init */
                rv = process_message_init(s);
                break;
            case 3: /* channel setup */
                rv = process_message_channel_setup(s);
                break;
            case 5: /* channel data */
                rv = process_message_channel_data(s);
                break;
            case 7: /* channel data response */
                rv = process_message_channel_data_response(s);
                break;
            default:
                LOGM((LOG_LEVEL_ERROR, "process_message: error in process_message ",
                      "unknown msg %d", id));
                break;
        }

        if (rv != 0)
        {
            break;
        }

        s->p = next_msg;
    }

    return rv;
}
Beispiel #8
0
void moVideoModule::start() {
	assert( this->video == NULL );
	LOGM(MO_TRACE, "start video");
	this->video = cvCaptureFromAVI(this->property("filename").asString().c_str());
	this->numframes = (int)cvGetCaptureProperty(static_cast<CvCapture *>(this->video), CV_CAP_PROP_FRAME_COUNT);
	moModule::start();
}
// ---------------------------------------------------------
// CDpDataBuffer::Flush
// This method empties the buffer and notifies waiting reader
// and writer about the flush.
// ---------------------------------------------------------
//
void CDpDataBuffer::Flush()
    {
    OstTrace0( TRACE_NORMAL, CDPDATABUFFER_FLUSH, "CDpDataBuffer::Flush" );
    LOGM(" CDpDataBuffer::Flush");

    // throw reader out
    //signal waiting reader
    if ( iIsReaderWaiting && iReader )
        {
        iReader->FlushNotify();
        iIsReaderWaiting = EFalse;
        }

    // throw writer out
    //signal waiting writer
    if ( iIsWriterWaiting && iWriter )
        {
        iWriter->FlushNotify();
        iIsWriterWaiting = EFalse;
        }

    // As (currently) data accesses to buffer are synchronous, there can be no
    // data client accessing the buffer.
    iEnd = 0;
    iHead = 0;
    iTail = 0;
    iTailWhenWrappedAround = 0;

    iBuf->Des().Fill( KDpFillChar );
    }
// ---------------------------------------------------------
// CDpDataBuffer::FreeBytes
// This method gets the amount of free bytes.
// ---------------------------------------------------------
//
TInt CDpDataBuffer::FreeBytes()
    {
    OstTrace0( TRACE_NORMAL, CDPDATABUFFER_FREEBYTES, "CDpDataBuffer::FreeBytes" );
    LOGM(" CDpDataBuffer::FreeBytes");

    return ( iBufSize - UsedBytes() - iMaxReservationSize );
    }
// ---------------------------------------------------------
// CDpDataBuffer::SetLength
// This method sets length of buffer. This is called from
// CDpDataPort::SetReceiveBufferLength() method.
// ---------------------------------------------------------
//
TInt CDpDataBuffer::SetLength(
    const TInt aLen)
    {
    OstTrace0( TRACE_NORMAL, CDPDATABUFFER_SETLENGTH, "CDpDataBuffer::SetLength" );
    LOGM(" CDpDataBuffer::SetLength");

    //Initialization
    TInt max( 0 );
    TInt ret( KErrNone );

    if ( iHead + iWE.iSize > iEnd )
        {
        max = iHead + iWE.iSize;
        }
    else
        {
        max = iEnd;
        }

        OstTraceExt2( TRACE_NORMAL, DUP1_CDPDATABUFFER_SETLENGTH, "CDpDataBuffer:: iHead: %d, iWE.iSize: %d", iHead, iWE.iSize );
        OstTraceExt2( TRACE_NORMAL, DUP2_CDPDATABUFFER_SETLENGTH, "CDpDataBuffer:: iEnd : %d, aLen     : %d", iEnd, aLen );

        LOG2("  iHead: %d, \t iWE.iSize: %d", iHead, iWE.iSize );
        LOG2("  iEnd : %d, \t aLen     : %d", iEnd, aLen );

    if ( ( max >= ( aLen + iMaxReservationSize ) ) ||
            ( aLen < 2*iMaxReservationSize ) )
        {
        // buffer may be filled further than length

        OstTrace0( TRACE_NORMAL, DUP3_CDPDATABUFFER_SETLENGTH, "CDpDataBuffer:: ERROR, Client tried to reserve too big or too small Receive Buffer Size" );
        OstTraceExt2( TRACE_NORMAL, DUP4_CDPDATABUFFER_SETLENGTH, "CDpDataBuffer:: aLen: %d, iMaxReservationSize: %d", aLen, iMaxReservationSize );
        OstTrace1( TRACE_NORMAL, DUP5_CDPDATABUFFER_SETLENGTH, "CDpDataBuffer:: max: %d", max );

        LOG("  ERROR, Client tried to reserve too big or too small Receive Buffer Size");
        LOG2("  aLen: %d, \t iMaxReservationSize: %d", aLen, iMaxReservationSize );
        LOG1("  max: %d", max );

        ret = KErrArgument;
        }
    else
        {
        iBuf->Des().SetLength( max );
        HBufC8* tmp = NULL;

        // ReAllocL returns address of the expanded or contracted HBufC descriptor.
        // ReAllocL() leaves, if there is insufficient memory.
        TRAP(ret, ( tmp = iBuf->ReAllocL( aLen+iMaxReservationSize ) ));

        if ( KErrNone == ret )
            {
            iBuf=tmp;
            iBuf->Des().SetLength( aLen + iMaxReservationSize );
            iBufSize = aLen + iMaxReservationSize;
            iTreshold = aLen;
            }
        }

    return ret;
    }
void RenderingModule::OnWindowSizeChanged(UINT32 p_uiWidth, UINT32 p_uiHeight, bool p_bMinimized)
{
	LOGM("Window size changed event received. Width=" << p_uiWidth << " Height=" << p_uiHeight << " Minimized=" << p_bMinimized, Info);
	m_bWindowMinimized = p_bMinimized;
	m_API->OnWindowSizeChanged(p_uiWidth, p_uiHeight);
	m_bWindowTransition = false;
}
int rmnet_vnd_create_dev(int id, struct net_device **new_device)
{
	struct net_device *dev;
	int rc = 0;

	if (id < 0 || id > RMNET_DATA_MAX_VND || rmnet_devices[id] != 0) {
		*new_device = 0;
		return -EINVAL;
	}

	dev = alloc_netdev(sizeof(struct rmnet_vnd_private_s),
			   RMNET_DATA_DEV_NAME_STR,
			   rmnet_vnd_setup);
	if (!dev) {
		LOGE("%s(): Failed to to allocate netdev for id %d",
		      __func__, id);
		*new_device = 0;
		return -EINVAL;
	}

	rc = register_netdevice(dev);
	if (rc != 0) {
		LOGE("%s(): Failed to to register netdev [%s]",
		      __func__, dev->name);
		free_netdev(dev);
		*new_device = 0;
	} else {
		rmnet_devices[id] = dev;
		*new_device = dev;
	}

	LOGM("%s(): Registered device %s\n", __func__, dev->name);
	return rc;
}
static void rmnet_vnd_setup(struct net_device *dev)
{
	struct rmnet_vnd_private_s *dev_conf;
	LOGM("%s(): Setting up device %s\n", __func__, dev->name);

	
	dev_conf = (struct rmnet_vnd_private_s *) netdev_priv(dev);
	memset(dev_conf, 0, sizeof(struct rmnet_vnd_private_s));

	
	dev->flags |= IFF_NOARP;
	dev->netdev_ops = &rmnet_data_vnd_ops;
	dev->mtu = RMNET_DATA_DFLT_PACKET_SIZE;
	dev->needed_headroom = RMNET_DATA_NEEDED_HEADROOM;
	random_ether_addr(dev->dev_addr);
	dev->watchdog_timeo = 1000;

	
	dev->header_ops = 0;  
	dev->type = ARPHRD_RAWIP;
	dev->hard_header_len = 0;
	dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST);

	
	rwlock_init(&dev_conf->flows.flow_map_lock);
}
Beispiel #15
0
void moBlobTrackerModule::allocateBuffers() {
	IplImage* src = static_cast<IplImage*>(this->input->getData());
	if ( src == NULL )
		return;
	this->output_buffer = cvCreateImage(cvGetSize(src), src->depth, 3);
	LOGM(MO_TRACE, "allocated output buffer for BlobTracker module.");
}
Beispiel #16
0
/* returns error */
int APP_CC
send_channel_data(int chan_id, char *data, int size)
{
    int index;

    //g_writeln("send_channel_data chan_id %d size %d", chan_id, size);

    LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: size %d", size));

    if (chan_id == -1)
    {
        g_writeln("send_channel_data: error, chan_id is -1");
        return 1;
    }

    for (index = 0; index < g_num_chan_items; index++)
    {
        if (g_chan_items[index].id == chan_id)
        {
            add_data_to_chan_item(g_chan_items + index, data, size);
            check_chan_items();
            return 0;
        }
    }

    return 1;
}
/**
 * rmnet_map_command() - Entry point for handling MAP commands
 * @skb: Socket buffer containing the MAP command message
 * @config: Physical end-point configuration of ingress device
 *
 * Process MAP command frame and send N/ACK message as appropriate. Message cmd
 * name is decoded here and appropriate handler is called.
 *
 * Return:
 *      - RX_HANDLER_CONSUMED. Command frames are always consumed.
 */
rx_handler_result_t rmnet_map_command(struct sk_buff *skb,
				      struct rmnet_phys_ep_conf_s *config)
{
	struct rmnet_map_control_command_s *cmd;
	unsigned char command_name;
	unsigned char rc = 0;

	if (unlikely(!skb))
		BUG();

	cmd = RMNET_MAP_GET_CMD_START(skb);
	command_name = cmd->command_name;

	if (command_name < RMNET_MAP_COMMAND_ENUM_LENGTH)
		rmnet_map_command_stats[command_name]++;

	switch (command_name) {
	case RMNET_MAP_COMMAND_FLOW_ENABLE:
		rc = rmnet_map_do_flow_control(skb, config, 1);
		break;

	case RMNET_MAP_COMMAND_FLOW_DISABLE:
		rc = rmnet_map_do_flow_control(skb, config, 0);
		break;

	default:
		rmnet_map_command_stats[RMNET_MAP_COMMAND_UNKNOWN]++;
		LOGM("Uknown MAP command: %d", command_name);
		rc = RMNET_MAP_COMMAND_UNSUPPORTED;
		break;
	}
	rmnet_map_send_ack(skb, rc, config);
	return RX_HANDLER_CONSUMED;
}
// ---------------------------------------------------------
// This method notifies that buffer is flushed. Classes which have access
// to buffers are derived from this class. Derived class could override
// this method, otherwise this default method will be used.
// release this cactive object
// ---------------------------------------------------------
//
void CDpDte2Tx::FlushNotify()
    {
    OstTrace0( TRACE_NORMAL, CDPDTE2TX_FLUSHNOTIFY, "CDpDte2Tx::FlushNotify" );
    LOGM(" CDpDte2Tx::FlushNotify()");

    ReleaseNotify();
    }
Beispiel #19
0
static void _rmnet_netlink_add_del_vnd_tc_flow
					(uint32_t command,
					 struct rmnet_nl_msg_s *rmnet_header,
					 struct rmnet_nl_msg_s *resp_rmnet)
{
	uint32_t id;
	uint32_t map_flow_id;
	uint32_t tc_flow_id;

	_RMNET_NETLINK_NULL_CHECKS();
	resp_rmnet->crd = RMNET_NETLINK_MSG_RETURNCODE;

	id = rmnet_header->flow_control.id;
	map_flow_id = rmnet_header->flow_control.map_flow_id;
	tc_flow_id = rmnet_header->flow_control.tc_flow_id;

	switch (command) {
	case RMNET_NETLINK_ADD_VND_TC_FLOW:
		resp_rmnet->return_code = rmnet_vnd_add_tc_flow(id,
								map_flow_id,
								tc_flow_id);
		break;
	case RMNET_NETLINK_DEL_VND_TC_FLOW:
		resp_rmnet->return_code = rmnet_vnd_del_tc_flow(id,
								map_flow_id,
								tc_flow_id);
		break;
	default:
		LOGM("Called with unhandled command %d", command);
		resp_rmnet->return_code = RMNET_CONFIG_INVALID_REQUEST;
		break;
	}
}
// -----------------------------------------------------------------------------
// CDpPn2Rx::FlushNotify
// This method notifies that buffer is flushed. Classes which have access
// to buffers are derived from this class. Derived class could override
// this method, otherwise this default method will be used.
// -----------------------------------------------------------------------------
//
void CDpPn2Rx::FlushNotify()
    {
    OstTrace0( TRACE_NORMAL, CDPPN2RX_FLUSHNOTIFY, "CDpPn2Rx::FlushNotify" );
    LOGM("CDpPn2Rx::FlushNotify()");

    ReleaseNotify();
    }
// ---------------------------------------------------------
// CDpMif::DoCancel
// This method cancels Isc Api receive.
// ---------------------------------------------------------
//
void CDpMif::DoCancel()
    {
    OstTrace0( TRACE_NORMAL, CDPMIF_DOCANCEL, "CDpMif::DoCancel" );
    LOGM(" CDpMif::DoCancel");

    iDataPort.ISAHandle().ReceiveCancel();
    }
// -----------------------------------------------------------------------------
// CDpPn2Rx::~CDpPn2Rx
// Destructor
// -----------------------------------------------------------------------------
//
CDpPn2Rx::~CDpPn2Rx()
    {
    OstTrace0( TRACE_NORMAL, DUP1_CDPPN2RX_CDPPN2RX, "CDpPn2Rx::~CDpPn2Rx" );
    LOGM("CDpPn2Rx::~CDpPn2Rx");
    // unregister from PIF as observer
    iPifDcs.Detach( iDpPn2RxObserver );
    }
void moCameraModule::start() {
	assert( this->camera == NULL );
	LOGM(MO_TRACE, "start camera");

	this->camera = cvCaptureFromCAM(this->property("index").asInteger());
	if ( this->camera == NULL ) {
		LOGM(MO_ERROR, "could not load camera: " << this->property("index").asInteger());
		this->setError("Unable to open camera");
	}
	cvSetCaptureProperty((CvCapture*)this->camera, CV_CAP_PROP_BRIGHTNESS, .01);
	cvSetCaptureProperty((CvCapture*)this->camera, CV_CAP_PROP_EXPOSURE, 0);
	//cvSetCaptureProperty((CvCapture*)this->camera, CV_CAP_PROP_SATURATION, 255);


	moModule::start();
}
Beispiel #24
0
void moImageModule::update() {
	if ( this->image != NULL ) {
		// push a new image on the stream
		LOGM(MO_TRACE, "push a new image on the stream");
		this->stream->push(this->image);
	}
}
Beispiel #25
0
void moCameraModule::stop() {
	moModule::stop();
	if ( this->camera != NULL ) {
		LOGM(MO_TRACE, "release camera");
		cvReleaseCapture((CvCapture **)&this->camera);
		this->camera = NULL;
	}
}
// ---------------------------------------------------------
// CDpDte2Tx::UpDate
// We are observer of FlowCtrl. E.g. when flow control
// status changes, we are called.
// ---------------------------------------------------------
//
void CDpDte2Tx::UpDate(
    CDpSubject* /*aChangedSubject*/)
    {
    OstTrace0( TRACE_NORMAL, CDPDTE2TX_UPDATE, "CDpDte2Tx::UpDate" );
    LOGM(" CDpDte2Tx::UpDate");

    ReleaseNotify();
    }
// -----------------------------------------------------------------------------
// CDpPn2Rx::ReleaseNotify
// This method signals ourselves.
// -----------------------------------------------------------------------------
//
void CDpPn2Rx::ReleaseNotify()
    {
    OstTrace0( TRACE_NORMAL, CDPPN2RX_RELEASENOTIFY, "CDpPn2Rx::ReleaseNotify" );
    LOGM("CDpPn2Rx::ReleaseNotify");

    // This is done because receive data might me also active
    DoCancel();
    }
Beispiel #28
0
void moImageModule::stop() {
	moModule::stop();
	if ( this->image != NULL ) {
		LOGM(MO_TRACE, "release Image");
		cvReleaseImage(&(this->image));
		this->image = NULL;
	}
}
Beispiel #29
0
/* this should be called first */
int APP_CC
xcommon_init(void)
{
    if (g_display != 0)
    {
        LOG(10, ("xcommon_init: xcommon_init already called"));
        return 0;
    }

    g_display = XOpenDisplay(0);

    if (g_display == 0)
    {
        LOGM((LOG_LEVEL_ERROR, "xcommon_init: error, XOpenDisplay failed"));
        return 1;
    }

    LOG(0, ("xcommon_init: connected to display ok"));

    /* setting the error handlers can cause problem when shutting down
       chansrv on some xlibs */
    XSetErrorHandler(xcommon_error_handler);
    //XSetIOErrorHandler(xcommon_fatal_handler);

    g_x_socket = XConnectionNumber(g_display);

    if (g_x_socket == 0)
    {
        LOGM((LOG_LEVEL_ERROR, "xcommon_init: XConnectionNumber failed"));
        return 1;
    }

    g_x_wait_obj = g_create_wait_obj_from_socket(g_x_socket, 0);
    g_screen_num = DefaultScreen(g_display);
    g_screen = ScreenOfDisplay(g_display, g_screen_num);

    g_root_window = RootWindowOfScreen(g_screen);

    g_wm_delete_window_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", 0);
    g_wm_protocols_atom = XInternAtom(g_display, "WM_PROTOCOLS", 0);
    g_utf8_string = XInternAtom(g_display, "UTF8_STRING", 0);
    g_net_wm_name = XInternAtom(g_display, "_NET_WM_NAME", 0);
    g_wm_state = XInternAtom(g_display, "WM_STATE", 0);
    
    return 0;
}
Beispiel #30
0
void moVideoModule::stop() {
	moModule::stop();
	if ( this->video != NULL ) {
		LOGM(MO_TRACE, "release video");
		cvReleaseCapture((CvCapture **)&this->video);
		this->video = NULL;
	}
}