예제 #1
0
void NetscapePluginStream::didReceiveData(const char* bytes, int length)
{
    // Delivering the data could cause the plug-in stream to go away so we keep a reference to it here.
    Ref<NetscapePluginStream> protect(*this);

    deliverData(bytes, length);
}
void PluginStream::didReceiveData(NetscapePlugInStreamLoader* loader, const char* data, int length)
{
    ASSERT(loader == m_loader);
    ASSERT(m_streamState == StreamStarted);

    // If the plug-in cancels the stream in deliverData it could be deleted, 
    // so protect it here.
    RefPtr<PluginStream> protect(this);

    if (m_transferMode != NP_ASFILEONLY) {
        if (!m_deliveryData)
            m_deliveryData.set(new Vector<char>);

        int oldSize = m_deliveryData->size();
        m_deliveryData->resize(oldSize + length);
        memcpy(m_deliveryData->data() + oldSize, data, length);

#if PLATFORM(ANDROID)
//TODO: This needs to be upstreamed to WebKit.
        if (!m_delayDeliveryTimer.isActive())
#endif
        deliverData();
    }

    if (m_streamState != StreamStopped && isHandleValid(m_tempFileHandle)) {
        int bytesWritten = writeToFile(m_tempFileHandle, data, length);
        if (bytesWritten != length)
            cancelAndDestroyStream(NPRES_NETWORK_ERR);
    }
}
예제 #3
0
void PluginStream::didReceiveData(NetscapePlugInStreamLoader* loader, const char* data, int length)
{
    ASSERT_UNUSED(loader, loader == m_loader);
    ASSERT(m_streamState == StreamStarted);

    // If the plug-in cancels the stream in deliverData it could be deleted, 
    // so protect it here.
    RefPtr<PluginStream> protect(this);

    if (m_transferMode != NP_ASFILEONLY) {
        if (!m_deliveryData)
            m_deliveryData = std::make_unique<Vector<char>>();

        int oldSize = m_deliveryData->size();
        m_deliveryData->resize(oldSize + length);
        memcpy(m_deliveryData->data() + oldSize, data, length);

        deliverData();
    }

    if (m_streamState != StreamStopped && isHandleValid(m_tempFileHandle)) {
        int bytesWritten = writeToFile(m_tempFileHandle, data, length);
        if (bytesWritten != length)
            cancelAndDestroyStream(NPRES_NETWORK_ERR);
    }
}
예제 #4
0
void NetscapePluginStream::sendJavaScriptStream(const String& result)
{
    // starting the stream or delivering the data to it might cause the plug-in stream to go away, so we keep
    // a reference to it here.
    Ref<NetscapePluginStream> protect(*this);

    CString resultCString = result.utf8();
    if (resultCString.isNull()) {
        // There was an error evaluating the JavaScript, call NPP_URLNotify if needed and then destroy the stream.
        notifyAndDestroyStream(NPRES_NETWORK_ERR);
        return;
    }

    if (!start(m_requestURLString, resultCString.length(), 0, "text/plain", ""))
        return;

    deliverData(resultCString.data(), resultCString.length());
    stop(NPRES_DONE);
}
예제 #5
0
HRESULT TheoraEncodeInputPin::encodeMoreFrames()
{
	HRESULT locHR = S_OK;

	__int64 frameTime = (1000 * m_theoraInfo.fps_denominator) / m_theoraInfo.fps_numerator;
	__int64 curTheoraTime = (m_numFrames * 1000 * m_theoraInfo.fps_denominator) / m_theoraInfo.fps_numerator;

	/* Resend previous packet, if we are too fast */
	while (m_dsTimeStart - curTheoraTime > frameTime) 
	{
		LONGLONG locFrameStart = m_uptoFrame;
		LONGLONG locFrameEnd = 0;

		StampedOggPacket* locPacket = m_theoraEncoder.encodeTheora(&m_yuv);
		if (locPacket == NULL) 
		{
			//debugLog<<"Encode returns NULL"<<endl;
			return S_FALSE;
		}
		locFrameEnd	= m_uptoFrame = locPacket->endTime();
		//debugLog<<"Delivering..."<<endl;

		//We still own the packet after this, we have to delete it.
		locHR = deliverData(locFrameStart, locFrameEnd, locPacket->packetData(), locPacket->packetSize());
		delete locPacket;
		if (FAILED(locHR)) 
		{
			break;
		}

		++m_numFrames;
		curTheoraTime = (m_numFrames * 1000 * m_theoraInfo.fps_denominator) / m_theoraInfo.fps_numerator;
	}

	return locHR;
}
void PluginStream::delayDeliveryTimerFired(Timer<PluginStream>* timer)
{
    ASSERT(timer == &m_delayDeliveryTimer);

    deliverData();
}
예제 #7
0
void PluginStream::delayDeliveryTimerFired()
{
    deliverData();
}
예제 #8
0
/*----------------------------------------------------------------------------*/
bool KsefBillItem :: assign(QDomElement& element)
{
  mN = element.attribute("N").toInt();
  switch(type())
  {
  case Sale:
  {
    SaleData *data = saleData();
    data->C = element.attribute("C").toInt();
    data->CD = element.attribute("CD");
    data->NM = element.attribute("NM");
    data->PRC = element.attribute("PRC").toInt();
    data->Q = element.attribute("Q").toInt();
    data->RT = element.attribute("RT").toInt();
    data->SM = element.attribute("SM").toInt();
    data->TX = element.attribute("TX").toInt();
    data->TX2 = element.attribute("TX2").toInt();
    break;
  }
  case Comment:
  {
    CommentData *data = commentData();
    data->TXT = element.text();
    break;
  }
  case Discount:
  {
    DiscountData *data = discountData();
    data->PR = element.attribute("PR").toInt();
    data->S = element.tagName() == "M";
    data->SM = element.attribute("SM").toInt();
    data->ST = element.attribute("ST").toInt();
    data->TR = element.attribute("TR").toInt();
    data->TY = element.attribute("TY").toInt();
    break;
  }
  case Sum:
  {
    SumData *data = sumData();
    data->CS = element.attribute("CS").toInt();
    data->NO = element.attribute("NO").toInt();
    data->SE = element.attribute("SE").toInt();
    data->SM = element.attribute("SM").toInt();
    //YYYYMMDDhhmmss
    QString t = element.attribute("TS");
    if(t.length() == 14)
    {
      int Y; int M; int D;
      int h, m, s;
      Y = t.left(4).toInt();
      M = t.mid(4, 2).toInt();
      D = t.mid(6, 2).toInt();
      h = t.mid(8, 2).toInt();
      m = t.mid(10, 2).toInt();
      s = t.mid(12, 2).toInt();

      data->TS.setDate(QDate(Y, M, D));
      data->TS.setTime(QTime(h, m, s, 0));
    }
    break;
  }
  case Tax:
  {
    TaxData *data = taxData();
    data->DTPR = element.attribute("DTPR").toInt();
    data->DTSM = element.attribute("DTSM").toInt();
    data->TX = element.attribute("TX").toInt();
    data->TXAL = element.attribute("TXAL").toInt();
    data->TXPR = element.attribute("TXPR").toInt();
    data->TXSM = element.attribute("TXSM").toInt();
    data->TXTY = element.attribute("TXTY").toInt();
    break;
  }
  case SaleFuel:
  {
    SaleFuelData *data = saleFuelData();
    data->C = element.attribute("C").toInt();
    data->CD = element.attribute("CD");
    data->KRK = element.attribute("KRK").toInt();
    data->NM = element.attribute("NM");
    data->OV = element.attribute("OV");
    data->PRC = element.attribute("PRC").toInt();
    data->PRK = element.attribute("PRK").toInt();
    data->Q = element.attribute("Q").toInt();
    data->SM = element.attribute("SM").toInt();
    data->TX = element.attribute("TX").toInt();
    data->TX2 = element.attribute("TX2").toInt();
    break;
  }
  case Payment:
  {
    PaymentData *data = paymentData();
    data->NM = element.attribute("NM");
    data->RM = element.attribute("RM").toInt();
    data->RRN = element.attribute("RRN");
    data->SM = element.attribute("SM").toInt();
    data->T = element.attribute("T").toInt();
    break;
  }
  case Receive:
  {
    ReseiveData *data = reseiveData();
    data->O = element.text() == "O";
    data->SM = element.attribute("SM").toInt();
    break;
  }
  case Deliver:
  {
    DeliverData *data = deliverData();
    data->C = element.attribute("C").toInt();
    data->NM = element.attribute("NM");
    data->NR = element.attribute("NR").toInt();
    data->OV = element.attribute("OV");
    data->Q = element.attribute("Q").toInt();
    break;
  }
  case PumpCheck:
  {
    PumpCheckData *data = pumpCheckData();
    data->C = element.attribute("C").toInt();
    data->KRK = element.attribute("KRK").toInt();
    data->NM = element.attribute("NM");
    data->OV = element.attribute("OV");
    data->PRK = element.attribute("PRK").toInt();
    data->Q = element.attribute("Q").toInt();
    break;
  }
  case ZTax:
  {
    ZTaxData *data = zTaxData();
    data->DTI = element.attribute("DTI").toInt();
    data->DTO = element.attribute("DTO").toInt();
    data->DTPR = element.attribute("DTPR").toInt();
    data->SMI = element.attribute("SMI").toInt();
    data->SMO = element.attribute("SMO").toInt();
    data->TX = element.attribute("TX").toInt();
    data->TXAL = element.attribute("TXAL").toInt();
    data->TXI = element.attribute("TXI").toInt();
    data->TXO = element.attribute("TXO").toInt();
    data->TXPR = element.attribute("TXPR").toInt();
    data->TXTY = element.attribute("TXTY").toInt();
    //YYYYMMDD
    QString t = element.attribute("TS");
    if(t.length() == 8)
    {
      int Y; int M; int D;
      Y = t.left(4).toInt();
      M = t.mid(4, 2).toInt();
      D = t.mid(6, 2).toInt();

      data->TS = QDate(Y, M, D);
    }
    break;
  }
  case ZReceive:
  {
    ZReseiveData *data = zReseiveData();
    data->SMI = element.attribute("SMI").toInt();
    data->SMO = element.attribute("SMO").toInt();
    break;
  }
  case ZBillCount:
  {
    ZBillCountData *data  = zBillCountData();
    data->NI = element.attribute("NI").toInt();
    data->NO = element.attribute("NO").toInt();
    break;
  }
  case ZPayment:
  {
    ZPaymentData *data = zPaymentData();
    data->NM = element.attribute("NM");
    data->SMI = element.attribute("SMI").toInt();
    data->SMO = element.attribute("SMO").toInt();
    data->T = element.attribute("T").toInt();
    break;
  }
  case ZFuel:
  {
    ZFuelData *data = zFuelData();
    data->C = element.attribute("C").toInt();
    data->IF = element.attribute("IF").toInt();
    data->NM = element.attribute("NM");
    data->OF = element.attribute("OF").toInt();
    data->OFP = element.attribute("OFP").toInt();
    data->SF = element.attribute("SF").toInt();
    data->SMI = element.attribute("SMI").toInt();
    break;
  }
  case ZTank:
  {
    ZTankData *data = zTankData();
    data->C = element.attribute("C").toInt();
    data->NR = element.attribute("NR").toInt();
    data->SF = element.attribute("SF").toInt();
    break;
  }
  case ZFPayment:
  {
    ZFPaymentData *data = zFPaymentData();
    data->C = element.attribute("C").toInt();
    data->NM = element.attribute("NM");
    data->OF = element.attribute("OF").toInt();
    data->SM = element.attribute("SM").toInt();
    data->T = element.attribute("T").toInt();
    break;
  }
  case ZPump:
  {
    ZPumpData *data = zPumpData();
    data->NP = element.attribute("NP").toInt();
    data->NR = element.attribute("NR").toInt();
    break;
  }
  default:
    return false;
  }
  return true;
}
예제 #9
0
//PURE VIRTUALS
long TheoraEncodeInputPin::TransformData(unsigned char* inBuf, long inNumBytes) {

	//TODO::: Break this function up a bit !!

	//Time stamps are granule pos not directshow times
	//debugLog<<"Encode data"<<endl;
	LONGLONG locFrameStart = m_uptoFrame;
	LONGLONG locFrameEnd = 0;
	HRESULT locHR = S_OK;
	if (!m_hasBegun) {
		//debugLog<<"encodeData : First time"<<endl;
		m_hasBegun = true;
		
		StampedOggPacket** locHeaders;
		locHeaders = m_theoraEncoder.initCodec(m_theoraInfo);

		for (int i = 0; i < 3; i++) {
			locHR = deliverData(0,0,locHeaders[i]->packetData(), locHeaders[i]->packetSize());
			delete locHeaders[i];
			if (locHR != S_OK) {
				return locHR;
			}
		}
	}


	//This big if block merely takes the buffer and copies it into the yuv_buffer structure which
	// is used below to encode.
	if (m_pinInputType.subtype == MEDIASUBTYPE_YUY2) {
		//debugLog<<"About to encode YUY2 to YV12"<<endl;
		encodeYUY2ToYV12(inBuf, inNumBytes);
	} else if (m_pinInputType.subtype == MEDIASUBTYPE_AYUV) {
		encodeAYUVtoYV12(inBuf, inNumBytes);

	} else if (m_pinInputType.subtype == MEDIASUBTYPE_RGB32) {
		encodeRGB32toYV12(inBuf, inNumBytes);

	} else if (m_pinInputType.subtype == MEDIASUBTYPE_RGB24) {
		encodeRGB24toYV12(inBuf, inNumBytes);


	} else if (m_pinInputType.subtype == MEDIASUBTYPE_YV12) {
		//Should be more specifc.
		//debugLog<<"About to encode YV12 to YV12"<<endl;
		encodeYV12ToYV12(inBuf, inNumBytes);
	} else if (m_pinInputType.subtype == MEDIASUBTYPE_UYVY) {
		
		
		encodeUYVYToYV12(inBuf, inNumBytes);

	} else if (m_pinInputType.subtype == MEDIASUBTYPE_YVYU) {
		
		
		encodeYVYUToYV12(inBuf, inNumBytes);
	} else if (m_pinInputType.subtype == MEDIASUBTYPE_IYUV) {
		
		
		encodeIYUVToYV12(inBuf, inNumBytes);

		
	} else {

		//FATAL ERROR
		throw 0;
	}
	
#ifdef ADAPT_FRAME_RATE
	__int64 frameTime = (1000 * m_theoraInfo.fps_denominator) / m_theoraInfo.fps_numerator;
	__int64 curTheoraTime = (m_numFrames * 1000 * m_theoraInfo.fps_denominator) / m_theoraInfo.fps_numerator;

	// Skip a frame if we are too late
	if (curTheoraTime - m_dsTimeStart > frameTime) 
	{
		//debugLog<<" too late: "<< curTheoraTime << "," << timeStart << ":" << frameTime <<endl;
		return S_OK;
	}
#endif


	StampedOggPacket* locPacket = m_theoraEncoder.encodeTheora(&m_yuv);
	if (locPacket == NULL) {
		//debugLog<<"Encode returns NULL"<<endl;
		return S_FALSE;
	}
	locFrameEnd		= m_uptoFrame 
					= locPacket->endTime();
	//debugLog<<"Delivering..."<<endl;

	//We still own the packet after this, we have to delete it.
	locHR = deliverData(locFrameStart, locFrameEnd, locPacket->packetData(), locPacket->packetSize());
	delete locPacket;


#ifdef ADAPT_FRAME_RATE
	if (!FAILED(locHR)) 
	{
		++m_numFrames;
		locHR = encodeMoreFrames();
	}
#endif

	return locHR;
}