Beispiel #1
0
	CURLLoader(const char *inURL, int inAuthType, const char *inUserPasswd,
              const char *inCookies, bool inDebug)
	{
		mState = urlInit;
		if (!sCurlM)
			sCurlM = curl_multi_init();
		mBytesTotal = -1;
		mBytesLoaded = 0;
		mHttpCode = 0;
		sLoaders++;
		mHandle = curl_easy_init();
		if (!sCurlMap)
			sCurlMap = new CurlMap;

		curl_easy_setopt(mHandle, CURLOPT_URL, inURL);

      /* send all data to this function  */ 
      curl_easy_setopt(mHandle, CURLOPT_WRITEFUNCTION, staticOnData);
      curl_easy_setopt(mHandle, CURLOPT_WRITEDATA, (void *)this);
		curl_easy_setopt(mHandle, CURLOPT_NOPROGRESS, 0);
      if (inAuthType!=0)
      {
         curl_easy_setopt(mHandle, CURLOPT_HTTPAUTH, inAuthType);
         if (inUserPasswd && inUserPasswd[0])
            curl_easy_setopt(mHandle, CURLOPT_USERPWD, inUserPasswd);
      }
      curl_easy_setopt(mHandle, CURLOPT_PROGRESSFUNCTION, staticOnProgress);
      curl_easy_setopt(mHandle, CURLOPT_PROGRESSDATA, (void *)this);
      curl_easy_setopt(mHandle, CURLOPT_ERRORBUFFER, mErrorBuf );
      if (inDebug)
         curl_easy_setopt(mHandle, CURLOPT_VERBOSE, 1);
      curl_easy_setopt( mHandle, CURLOPT_COOKIEFILE, "" );
      if (inCookies && inCookies[0])
         curl_easy_setopt( mHandle, CURLOPT_COOKIE, inCookies );
      curl_easy_setopt(mHandle, CURLOPT_CAINFO, sCACertFile.c_str());
 
      mErrorBuf[0] = '\0';
 
      /* some servers don't like requests that are made without a user-agent
         field, so we provide one */ 
      curl_easy_setopt(mHandle, CURLOPT_USERAGENT, "libcurl-agent/1.0");

		mState = urlLoading;

      if (sCurlMap->size()<MAX_ACTIVE)
      {
         StartProcessing();
      }
      else
      {
         if (sCurlList==0)
           sCurlList = new CurlList;
         sCurlList->push_back(this);
      }
   }
Beispiel #2
0
    void process_first(Packet_RECALL recall)
    {
        ASSERT( !active );

        tid=recall.tid;
        client_slot=recall.client_slot;
        client_info=recall.client_info;

        number=recall.number;
        ready=false;
        canceled=false;
        timeout=0;
        active=true;

        StartProcessing(server_slot);
    }
Beispiel #3
0
    void process(Packet_CALL call)
    {
        ASSERT( !active );

        tid=call.tid;
        client_slot=call.client_slot;
        client_info=call.client_info;

        number=0;
        ready=false;
        canceled=false;
        timeout=0;
        active=true;

        StartProcessing(server_slot);
    }
void StreamService::operator()()
{
	Thread loadThread("Loader");
	loadThread.startThread(std::ref(loader));

	currentBuffer = &streamBufferA;

	UInt32 bufferOffset = 0;
	loader.ReadyForData();
	InitialDataMove(bufferOffset);
	StartProcessing();

	while (IsStreaming())
	{
		coordCV.wait(lock);

		StreamBuffer* currBuff = GetActiveBuffer();
		
		musicRef->PushData(currBuff, ByteSubmissionAmount, bufferOffset);

		bufferOffset += ByteSubmissionAmount;

		if (bufferOffset >= currBuff->numBytesInBuffer)
		{
			if (LastBuffer)
			{
				musicRef->StopProcessing();
				SetStreaming(FALSE);
			}
			currBuff->hasData = FALSE;
			SwapActiveBuffer();
			bufferOffset = 0;
			loader.ReadyForData();
		}
	}

	loadThread.join();

	streamer->StreamEnded(this);
}
Beispiel #5
0
/**
 *  buffer header callback function for video
 *
 * @param port Pointer to port from which callback originated
 * @param buffer mmal buffer header pointer
 */
static void video_buffer_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
{
   MMAL_BUFFER_HEADER_T *new_buffer;
   PORT_USERDATA *pData = (PORT_USERDATA *)port->userdata;

   if (pData)
   {

      if (buffer->length)
      {

          mmal_buffer_header_mem_lock(buffer);

        //
        // *** PR : OPEN CV Stuff here !
        //
        int w=pData->pstate->width;	// get image size
        int h=pData->pstate->height;
        int h4=h/4;

        memcpy(py->imageData,buffer->data,w*h);	// read Y

        if (pData->pstate->graymode==0)
        {
            memcpy(pu->imageData,buffer->data+w*h,w*h4); // read U
            memcpy(pv->imageData,buffer->data+w*h+w*h4,w*h4); // read v

            cvResize(pu, pu_big, CV_INTER_NN);
            cvResize(pv, pv_big, CV_INTER_NN);  //CV_INTER_LINEAR looks better but it's slower
            cvMerge(py, pu_big, pv_big, NULL, image);

            cvCvtColor(image,dstImage,CV_YCrCb2RGB);	// convert in RGB color space (slow)

            StartProcessing(dstImage, gVideoProcessor);

            cvShowImage("camcvWin", dstImage );
        }
        else
        {
            cvShowImage("camcvWin", py); // display only gray channel
        }

        cvWaitKey(1);
        nCount++;		// count frames displayed

         mmal_buffer_header_mem_unlock(buffer);
      }
      else vcos_log_error("buffer null");

   }
   else
   {
      vcos_log_error("Received a encoder buffer callback with no state");
   }

   // release buffer back to the pool
   mmal_buffer_header_release(buffer);

   // and send one back to the port (if still open)
   if (port->is_enabled)
   {
      MMAL_STATUS_T status;

      new_buffer = mmal_queue_get(pData->pstate->video_pool->queue);

      if (new_buffer)
         status = mmal_port_send_buffer(port, new_buffer);

      if (!new_buffer || status != MMAL_SUCCESS)
         vcos_log_error("Unable to return a buffer to the encoder port");
   }

}
Beispiel #6
0
void FSBrowser::processingEntries()
{
    StartProcessing();
}
Beispiel #7
0
//ProcessOne() takes a track, transforms it to bunch of buffer-blocks,
//and executes AnalyzeData, then ProcessData, on it...
bool EffectNormalize::ProcessOne(WaveTrack * track,
                                  sampleCount start, sampleCount end)
{
   bool rc = true;
   
   sampleCount s;
   //Get the length of the buffer (as double). len is
   //used simple to calculate a progress meter, so it is easier
   //to make it a double now than it is to do it later 
   double len = (double)(end - start);

   //Initiate a processing buffer.  This buffer will (most likely)
   //be shorter than the length of the track being processed.
   float *buffer = new float[track->GetMaxBlockSize()];

   int pass;

   for(pass=0; pass<2; pass++)
   {
      if(pass==0 && !mDC)  // we don't need an analysis pass if not doing dc removal
         continue;
      if (pass==0)
         StartAnalysis();  // dc offset only.  Max/min done in Process().
      if (pass==1)
         StartProcessing();

      //Go through the track one buffer at a time. s counts which
      //sample the current buffer starts at.
      s = start;
      while (s < end) {
         //Get a block of samples (smaller than the size of the buffer)
         sampleCount block = track->GetBestBlockSize(s);
         
         //Adjust the block size if it is the final block in the track
         if (s + block > end)
            block = end - s;
         
         //Get the samples from the track and put them in the buffer
         track->Get((samplePtr) buffer, floatSample, s, block);
         
         //Process the buffer.

         if (pass==0)
            AnalyzeData(buffer, block);

         if (pass==1) {
            ProcessData(buffer, block);
         
            //Copy the newly-changed samples back onto the track.
            track->Set((samplePtr) buffer, floatSample, s, block);
         }
            
         //Increment s one blockfull of samples
         s += block;
         
         //Update the Progress meter
			if (TrackProgress(mCurTrackNum, 
									((double)(pass)*0.5) + // Approximate each pass as half.
                           ((double)(s - start) / (len*2)))) {
            rc = false; //lda .. break, not return, so that buffer is deleted
            break;
         }
      }
   }
   //Clean up the buffer
   delete[] buffer;

   //Return true because the effect processing succeeded ... unless cancelled
   return rc;
}
Beispiel #8
0
	CURLLoader(URLRequest &r)
	{
		mState = urlInit;
		if (!sCurlM)
			sCurlM = curl_multi_init();
		mBytesTotal = -1;
		mBytesLoaded = 0;
		mHttpCode = 0;
		sLoaders++;
		mHandle = curl_easy_init();
		if (!sCurlMap)
			sCurlMap = new CurlMap;

    mBufferRemaining = 0;
    mPutBuffer = 0;
    mBufferPos = 0;
    headerlist = NULL;

		curl_easy_setopt(mHandle, CURLOPT_URL, r.url);

    /* send all data to this function  */ 
    curl_easy_setopt(mHandle, CURLOPT_WRITEFUNCTION, staticOnData);
    curl_easy_setopt(mHandle, CURLOPT_WRITEDATA, (void *)this);
		curl_easy_setopt(mHandle, CURLOPT_NOPROGRESS, 0);
		curl_easy_setopt(mHandle, CURLOPT_FOLLOWLOCATION, 1);
    if (r.authType!=0)
    {
      curl_easy_setopt(mHandle, CURLOPT_HTTPAUTH, r.authType);
      if (r.credentials && r.credentials[0])
        curl_easy_setopt(mHandle, CURLOPT_USERPWD, r.credentials);
    }
    curl_easy_setopt(mHandle, CURLOPT_PROGRESSFUNCTION, staticOnProgress);
    curl_easy_setopt(mHandle, CURLOPT_PROGRESSDATA, (void *)this);
    curl_easy_setopt(mHandle, CURLOPT_ERRORBUFFER, mErrorBuf );
    if (r.debug)
      curl_easy_setopt(mHandle, CURLOPT_VERBOSE, 1);
    curl_easy_setopt( mHandle, CURLOPT_COOKIEFILE, "" );
    if (r.cookies && r.cookies[0])
      curl_easy_setopt( mHandle, CURLOPT_COOKIE, r.cookies );
    if (sCACertFile.empty())
      curl_easy_setopt(mHandle, CURLOPT_SSL_VERIFYPEER, false);
    else
      curl_easy_setopt(mHandle, CURLOPT_CAINFO, sCACertFile.c_str());

    if (r.method)
    { 
      if (!strcmp(r.method,"POST"))
      {
        curl_easy_setopt(mHandle, CURLOPT_POST, true);

        if (r.postData.Ok())
        {
          curl_easy_setopt(mHandle, CURLOPT_POSTFIELDSIZE, r.postData.Size());
          curl_easy_setopt(mHandle, CURLOPT_COPYPOSTFIELDS, r.postData.Bytes());
        }
      }
      else if (!strcmp(r.method,"PUT"))
      {
        // The file to PUT must be set with CURLOPT_INFILE and CURLOPT_INFILESIZE.
        curl_easy_setopt(mHandle, CURLOPT_PUT, true);

        curl_easy_setopt(mHandle, CURLOPT_UPLOAD, 1);
        if (r.postData.Ok())
          SetPutBuffer(r.postData.Bytes(),r.postData.Size());
      } 
      else if (!strcmp(r.method,"GET"))
      {
        // GET is the default, so this is not necessary but here for completeness.
        curl_easy_setopt(mHandle, CURLOPT_HTTPGET, true);
      }
      else if (!strcmp(r.method,"DELETE"))
      {
        curl_easy_setopt(mHandle, CURLOPT_CUSTOMREQUEST, r.method);
      }
      else
      {
        // unsupported method !!
      }
    }

    if (r.contentType)
    {
      std::vector<char> buffer;
      buffer.resize(512);
      snprintf(&buffer[0], buffer.size(), "Content-Type: %s", r.contentType);
      headerlist = curl_slist_append(headerlist, &buffer[0]);
    }
    headerlist = curl_slist_append(headerlist, "Expect:");

    int n = r.headers.size();
    if (n >= 0) {
      for(int i = 0; i < n; i++)
      {
        URLRequestHeader h = r.headers[i];
        std::vector<char> buffer;
        buffer.resize(strlen(h.name) + strlen(h.value) + 3); // 1 for terminating char, 2 for ': '
        snprintf(&buffer[0], buffer.size(), "%s: %s", h.name, h.value);
        headerlist = curl_slist_append(headerlist, &buffer[0]);
      }
    }

    curl_easy_setopt(mHandle, CURLOPT_HTTPHEADER, headerlist);
 
    mErrorBuf[0] = '\0';
 
    /* some servers don't like requests that are made without a user-agent
      field, so we provide one */ 
    curl_easy_setopt(mHandle, CURLOPT_USERAGENT, "libcurl-agent/1.0");

		mState = urlLoading;

    if (sCurlMap->size()<MAX_ACTIVE)
    {
      StartProcessing();
    }
    else
    {
      if (sCurlList==0)
        sCurlList = new CurlList;
      sCurlList->push_back(this);
    }
  }