//------------------------------------------------------------------------------ void ofxMatrixNetworkServer::sendFrame(const ofPixelsRef pixels) { //for each connected client lets get the data being sent and lets print it to the screen for(unsigned int i = 0; i < (unsigned int)getLastID(); i++){ if(isClientConnected(i) && tx_valid[i] == 2){ tx_valid[i] = 1; int planecount = pixels.getNumChannels(); int dimcount = 2; // only sending 2d matrices from of int dim[dimcount]; dim[0] = pixels.getWidth(); dim[1] = pixels.getHeight(); int typeSize = pixels.getBytesPerChannel(); int type = JIT_MATRIX_TYPE_CHAR; makeMatrixHeader(planecount, typeSize, type, dim, dimcount); char *matrix = (char*)pixels.getPixels(); //////SEND ONE MATRIX sendRawBytes(i, (char *)(&m_chunkHeader), sizeof(t_jit_net_packet_header)); sendRawBytes(i, (char *)(&m_matrixHeader), sizeof(t_jit_net_packet_matrix)); //DELETE THIS LINE //int packSize = SWAP32(m_matrixHeader.dimstride[dimcount-1])*SWAP32(m_matrixHeader.dim[dimcount-1]); //ofLog(OF_LOG_NOTICE, "send frame to client: " + ofToString(i)); int vector = dim[0] * typeSize * planecount; for(int j = 0; j < dim[1]; j++){ sendRawBytes(i, matrix + j * vector, vector); } } } }
//------------------------------------------------------------------------------ void ofxJitterNetworkSender::sendFrame(const ofPixelsRef pixels) { int planecount = pixels.getNumChannels(); int dimcount = 2; // only sending 2d matrices from of int dim[dimcount]; dim[0] = pixels.getWidth(); dim[1] = pixels.getHeight(); int typeSize = pixels.getBytesPerChannel(); int type = JIT_MATRIX_TYPE_CHAR; makeMatrixHeader(planecount, typeSize, type, dim, dimcount); char *matrix = (char*)pixels.getPixels(); //////SEND ONE MATRIX sendRawBytes((char *)(&m_chunkHeader), sizeof(t_jit_net_packet_header)); sendRawBytes((char *)(&m_matrixHeader), sizeof(t_jit_net_packet_matrix)); int packSize = SWAP32(m_matrixHeader.dimstride[SWAP32(m_matrixHeader.dimcount)-1]) * SWAP32(m_matrixHeader.dim[SWAP32(m_matrixHeader.dimcount)-1]); sendRawBytes(matrix, packSize); }