Ejemplo n.º 1
0
void
MediaSourceDecoder::SetMediaSourceDuration(double aDuration, MSRangeRemovalAction aAction)
{
  MOZ_ASSERT(NS_IsMainThread());
  ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
  double oldDuration = ExplicitDuration();
  if (aDuration >= 0) {
    int64_t checkedDuration;
    if (NS_FAILED(SecondsToUsecs(aDuration, checkedDuration))) {
      // INT64_MAX is used as infinity by the state machine.
      // We want a very bigger number, but not infinity.
      checkedDuration = INT64_MAX - 1;
    }
    SetExplicitDuration(aDuration);
  } else {
    SetExplicitDuration(PositiveInfinity<double>());
  }
  if (!mIsUsingFormatReader && GetReader()) {
    GetReader()->SetMediaSourceDuration(ExplicitDuration());
  }

  if (mMediaSource && aAction != MSRangeRemovalAction::SKIP) {
    mMediaSource->DurationChange(oldDuration, aDuration);
  }
}
SKYETEK_STATUS 
SkyetekReaderFactory_CreateReader(
  LPSKYETEK_DEVICE    device, 
  LPSKYETEK_READER    *reader
  )
{
  LPSKYETEK_READER lpReader;
  LPDEVICEIMPL lpDI;
  unsigned int ix = 0;
  unsigned int ver = 0;

	if( device == NULL || device->readFD == 0 || device->internal == NULL )
    return SKYETEK_INVALID_PARAMETER; /*BAD_DEVICE*/
  
  lpDI = (LPDEVICEIMPL)device->internal;
  ver = GetReaderVersion(device);
  if( ver == 0 && _tcscmp(device->type,SKYETEK_USB_DEVICE_TYPE) == 0 )
  {
    lpDI->Flush(device);
    lpDI->Close(device);
    lpDI->Open(device);
    ver = GetReaderVersion(device);
  }

  // handle different versions
  if( ver == 2 ) 
  {
    lpReader = GetReader(device,&STPV2Impl,ver);
  } 
  else if( ver == 3 )
  {
    lpReader = GetReader(device,&STPV3Impl,ver);
  }
  else if( ver == -1 )
  {
    // bootload mode
    lpReader = GetBootloadReader(device,&STPV3Impl,3);
  }
  else
  {    
    return SKYETEK_INVALID_PARAMETER;
  }

  if( lpReader == NULL )
    return SKYETEK_INVALID_PARAMETER;

  *reader = lpReader;
  return SKYETEK_SUCCESS;
}
Ejemplo n.º 3
0
TAG_METHOD_IMPL(CWSDLBindingParser, OnOperation)
{
	TRACE_PARSE_ENTRY();
	
	CWSDLBinding * pCurr = GetBinding();
	if (pCurr != NULL)
	{
		CAutoPtr<CWSDLPortTypeOperation> spElem;
		spElem.Attach( new CWSDLPortTypeOperation );

		if (spElem != NULL)
		{
			SetXMLElementInfo(spElem, pCurr, GetLocator());

			CAutoPtr<CWSDLOperationParser> p( new CWSDLOperationParser(GetReader(), this, GetLevel(), spElem) );
			if (p)
			{
				if (g_ParserList.AddHead(p) != NULL)
				{
					if (SUCCEEDED(p.Detach()->GetAttributes(pAttributes)))
					{
						if (pCurr->AddOperation(spElem) != NULL)
						{
							spElem.Detach();
							return S_OK;
						}
					}
				}
			}
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);
	return E_FAIL;
}
Ejemplo n.º 4
0
TAG_METHOD_IMPL(CElementParser, OnComplexType)
{
    TRACE_PARSE_ENTRY();

    CElement * pCurr = GetElement();
    if (pCurr != NULL)
    {
        CComplexType * pElem = pCurr->AddComplexType();
        if (pElem != NULL)
        {
            SetXSDElementInfo(pElem, pCurr, GetLocator());

            CAutoPtr<CComplexTypeParser> p( new CComplexTypeParser(GetReader(), this, GetLevel(), pElem) );
            if (p != NULL)
            {
                if (g_ParserList.AddHead(p) != NULL)
                {
                    return p.Detach()->GetAttributes(pAttributes);
                }
            }
        }
    }

    EmitErrorHr(E_OUTOFMEMORY);
    return E_FAIL;
}
Ejemplo n.º 5
0
int main(void)
{
	// 配置读卡器
	Reader* reader = new Reader();
	reader->readerId = 248; // 读卡器id
	
	// 获取读卡器
	if (0 != GetReader(reader, 10000, 10000))
	{
		printf("getReader Failed.");
		return -1;
	}
	
	// 获取读卡器id
	{
		char devID[512] = {0};
		int readerId = 0;
		if (0 != GetDevIDAndReaderId(reader, devID, 512, readerId))
		{
			printf("GetDevIDAndReaderId Failed.");
		}
 		cout << devID << ", " << readerId << endl;
	}

	// 读取程序版本和终端类型
	{
		char appVer[512] = {0};
		char devType[512] = {0};
		if (0 != GetAppVerAndDevType(reader, appVer, 512, devType, 512))
		{
			printf("GetAppVerAndDevType Failed.");
		}
		cout << "程序版本: " << appVer << ", 终端类型: " << devType << endl;
	}

	// 获取芯片id(调用复位之后调用这个, 会出错)
	{
		char chipID[512] = {0};
		if (0 != GetChipID(reader, chipID, 512))
		{
			printf("GetChipID failed.");
		}
		cout << "芯片id: " << chipID << endl;
	}

	// 查看波特率
	{
		int braudRate = 0;
		if (0 != GetCardBraudRate(reader, braudRate))
		{
			printf("ModifyCardBraudRate failed.");
		}
		cout << "波特率: " << braudRate << endl;
	}
	
	// 释放内存
	delete reader;

	return 0;
}
Ejemplo n.º 6
0
CXbtManager::XBTFReaders::const_iterator CXbtManager::ProcessFile(const CURL& path) const
{
  std::string filePath = NormalizePath(path);

  // check if the file is known
  auto it = GetReader(filePath);
  if (it != m_readers.end())
  {
    // check if the XBT file has been modified
    if (it->second.reader->GetLastModificationTimestamp() <= it->second.lastModification)
      return it;

    // the XBT file has been modified so close and remove it from the cache
    // it will be re-opened by the following logic
    RemoveReader(it);
  }

  // try to read the file
  CXBTFReaderPtr reader(new CXBTFReader());
  if (!reader->Open(filePath))
    return m_readers.end();

  XBTFReader xbtfReader = {
    reader,
    reader->GetLastModificationTimestamp()
  };
  std::pair<XBTFReaders::iterator, bool> result = m_readers.insert(std::make_pair(filePath, xbtfReader));
  return result.first;
}
Ejemplo n.º 7
0
TAG_METHOD_IMPL(CWSDLOperationParser, OnFault)
{
	TRACE_PARSE_ENTRY();

	CWSDLPortTypeOperation * pCurr = GetOperation();
	if (pCurr != NULL)
	{
		CWSDLPortTypeFault * pElem = pCurr->AddFault();
		if (pElem != NULL)
		{
			SetXMLElementInfo(pElem, pCurr, GetLocator());
			CAutoPtr<CWSDLOperationIOParser> p( new CWSDLOperationIOParser(GetReader(), this, GetLevel(), pElem) );
			if (p != NULL)
			{
				if (g_ParserList.AddHead(p) != NULL)
				{
					return p.Detach()->GetAttributes(pAttributes);
				}
			}
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 8
0
void CXbtManager::Release(const CURL& path)
{
  const auto& it = GetReader(path);
  if (it == m_readers.end())
    return;

  RemoveReader(it);
}
Ejemplo n.º 9
0
void
MediaSourceDecoder::GetMozDebugReaderData(nsAString& aString)
{
  if (mIsUsingFormatReader) {
    return;
  }
  GetReader()->GetMozDebugReaderData(aString);
}
Ejemplo n.º 10
0
void
MediaSourceDecoder::PrepareReaderInitialization()
{
  if (mIsUsingFormatReader) {
    return;
  }
  MOZ_ASSERT(mReader);
  GetReader()->PrepareInitialization();
}
Ejemplo n.º 11
0
void
MediaSourceDecoder::Ended(bool aEnded)
{
  ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
  static_cast<MediaSourceResource*>(GetResource())->SetEnded(aEnded);
  if (!mIsUsingFormatReader) {
    GetReader()->Ended(aEnded);
  }
  mEnded = true;
  mon.NotifyAll();
}
Ejemplo n.º 12
0
bool Platform::GetFileSizeByName(string const & fileName, uint64_t & size) const
{
  try
  {
    size = ReaderPtr<Reader>(GetReader(fileName)).Size();
    return true;
  }
  catch (RootException const & ex)
  {
    LOG(LWARNING, ("Can't get file size for:", fileName));
    return false;
  }
}
Ejemplo n.º 13
0
already_AddRefed<nsZipArchive>
Omnijar::GetReader(nsIFile* aPath)
{
  NS_ABORT_IF_FALSE(IsInitialized(), "Omnijar not initialized");

  bool equals;
  nsresult rv;

  if (sPath[GRE] && !sIsNested[GRE]) {
    rv = sPath[GRE]->Equals(aPath, &equals);
    if (NS_SUCCEEDED(rv) && equals) {
      return GetReader(GRE);
    }
  }
  if (sPath[APP] && !sIsNested[APP]) {
    rv = sPath[APP]->Equals(aPath, &equals);
    if (NS_SUCCEEDED(rv) && equals) {
      return GetReader(APP);
    }
  }
  return nullptr;
}
Ejemplo n.º 14
0
bool CXbtFile::GetReaderAndFile(const CURL& url, CXBTFReaderPtr& reader, CXBTFFile& file)
{
  if (!GetReader(url, reader))
    return false;

  CURL xbtUrl(url);
  xbtUrl.SetOptions("");

  // CXBTFReader stores all filenames in lower case
  std::string fileName = xbtUrl.GetFileName();
  StringUtils::ToLower(fileName);

  return reader->Get(fileName, file);
}
Ejemplo n.º 15
0
IReader* CNetCacheAPI::GetData(const string& key, size_t* blob_size,
    CNetCacheAPI::ECachingMode caching_mode)
{
    try {
        return GetReader(key, blob_size, caching_mode);
    } catch (CNetCacheException& e) {
        switch (e.GetErrCode()) {
        case CNetCacheException::eBlobNotFound:
        case CNetCacheException::eAccessDenied:
            return NULL;
        }
        throw;
    }
}
Ejemplo n.º 16
0
bool CXmlSerializeHelper::Read(ISerializedObject *pObject, TSerializeFunc serializeFunc, void *pArgument /*= NULL*/)
{
	assert(pObject);

	bool bResult = false;

	if (CXmlSerializedObject *pXmlObject = GetXmlSerializedObject(pObject))
	{
		ISerialize *pReader = GetReader(pXmlObject->GetXmlNode());

		TSerialize stateReader(pReader);
		bResult = serializeFunc(stateReader, pArgument);
	}

	return bResult;
}
Ejemplo n.º 17
0
void CHPGLParser::Parse()
{
	if (IsToken(F("SP"), false, false) || IsToken(F("LT"), false, false))	{ IgnoreCommand();		return; }
	if (IsToken(F("IN"), false, false))										{ InitCommand();		return; }
	if (IsToken(F("PD"), false, false))										{ PenMoveCommand(PD);	return; }
	if (IsToken(F("PU"), false, false))										{ PenMoveCommand(PU);	return; }
	if (IsToken(F("PA"), false, false))										{ PenMoveCommand(PA);	return; }
	if (IsToken(F("PR"), false, false))										{ PenMoveCommand(PR);	return; }

	// command escape to "own" extension

	CHelpParser mycommand(GetReader(),GetOutput());
	mycommand.ParseCommand();

	if (mycommand.IsError()) Error(mycommand.GetError());
	_OkMessage = mycommand.GetOkMessage();
}
Ejemplo n.º 18
0
LIB_EXPORT rc_t CC RefSeq_Read(const RefSeq* cself, INSDC_coord_zero offset, INSDC_coord_len len,
                               uint8_t* buffer, INSDC_coord_len* written)
{
    rc_t rc = 0;

    if (cself == NULL || buffer == NULL || written == NULL)
        rc = RC(rcAlign, rcFile, rcReading, rcParam, rcNull);
    else {
        RefSeq *const self = (RefSeq *)cself;
        RefSeqMgr *const mgr = (RefSeqMgr *)self->mgr;
        
        rc = GetReader(mgr, self);
        if (rc == 0)
            rc = self->vt->read(self, offset, len, buffer, written);
    }
    ALIGN_DBGERR(rc);
    return rc;
}
Ejemplo n.º 19
0
TAG_METHOD_IMPL(CSchemaParser, OnElement)
{
	TRACE_PARSE_ENTRY();

	CSchema * pCurr = GetSchema();
	if (pCurr != NULL)
	{
		CAutoPtr<CElement> spElem;
		spElem.Attach( new CElement );
		if (spElem != NULL)
		{
			SetXSDElementInfo(spElem, pCurr, GetLocator());
			spElem->SetParentSchema(pCurr);

			CAutoPtr<CElementParser> p( new CElementParser(GetReader(), this, GetLevel(), spElem) );
			if (p != NULL)
			{
				if (g_ParserList.AddHead(p) != NULL)
				{
					if (SUCCEEDED(p.Detach()->GetAttributes(pAttributes)))
					{
						if (spElem->GetName().GetLength() != 0)
						{
							if (pCurr->AddElement(spElem) != NULL)
							{
								spElem.Detach();
								return S_OK;
							}
						}
						EmitNamedElementError("element");
					}
				}
			}
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 20
0
TAG_METHOD_IMPL(CComplexTypeParser, OnComplexContent)
{
	TRACE_PARSE_ENTRY();

	CComplexType *pCurr = GetComplexType();

	if (pCurr != NULL)
	{
		if (pCurr->GetElementType() == XSD_COMPLEXTYPE)
		{
			CContent *pElem = pCurr->AddContent();
			if (pElem != NULL)
			{
				SetXSDElementInfo(pElem, pCurr, GetLocator());
				pElem->SetElementType(XSD_COMPLEXCONTENT);

				CAutoPtr<CContentParser> p( new CContentParser(GetReader(), this, GetLevel(), pElem) );
				if (p != NULL)
				{
					if (g_ParserList.AddHead(p) != NULL)
					{
						return p.Detach()->GetAttributes(pAttributes);
					}
				}
			}
		}
		else
		{
			return OnUnrecognizedTag(wszNamespaceUri, 
				cchNamespaceUri, wszLocalName, cchLocalName, 
				wszQName, cchQName, pAttributes);
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Ejemplo n.º 21
0
static rc_t GetSeqInternal(RefSeqMgr *const self,
                              RefSeq const **const result,
                              unsigned const seq_id_sz,
                              char const seq_id[])
{
    RefSeq *obj = NULL;
    
    if (self->mru == NULL || self->mru->vt->compare(self->mru, seq_id_sz, seq_id) != 0) {
        rc_t const rc = GetSeq(self, &obj, seq_id_sz, seq_id);
        if (rc)
            return rc;
    }
    else
        obj = self->mru;
    {
        rc_t const rc = GetReader(self, obj);
        if (rc)
            return rc;
    }
    obj->vt->setRow(obj, seq_id_sz, seq_id);
    *result = obj;
    return 0;
}
Ejemplo n.º 22
0
nsresult
MediaSourceDecoder::SetCDMProxy(CDMProxy* aProxy)
{
  nsresult rv = MediaDecoder::SetCDMProxy(aProxy);
  NS_ENSURE_SUCCESS(rv, rv);
  if (!mIsUsingFormatReader) {
    rv = GetReader()->SetCDMProxy(aProxy);
    NS_ENSURE_SUCCESS(rv, rv);
  }
  if (aProxy) {
    // The sub readers can't decrypt EME content until they have a CDMProxy,
    // and the CDMProxy knows the capabilities of the CDM. The MediaSourceReader
    // remains in "waiting for resources" state until then. We need to kick the
    // reader out of waiting if the CDM gets added with known capabilities.
    CDMCaps::AutoLock caps(aProxy->Capabilites());
    if (!caps.AreCapsKnown()) {
      nsCOMPtr<nsIRunnable> task(
        NS_NewRunnableMethod(this, &MediaDecoder::NotifyWaitingForResourcesStatusChanged));
      caps.CallOnMainThreadWhenCapsAvailable(task);
    }
  }
  return NS_OK;
}
Ejemplo n.º 23
0
already_AddRefed<SourceBufferDecoder>
MediaSourceDecoder::CreateSubDecoder(const nsACString& aType, int64_t aTimestampOffset)
{
  MOZ_ASSERT(mReader && !mIsUsingFormatReader);
  return GetReader()->CreateSubDecoder(aType, aTimestampOffset);
}
Ejemplo n.º 24
0
void
MediaSourceDecoder::RemoveTrackBuffer(TrackBuffer* aTrackBuffer)
{
  MOZ_ASSERT(mReader && !mIsUsingFormatReader);
  GetReader()->RemoveTrackBuffer(aTrackBuffer);
}
Ejemplo n.º 25
0
void
MediaSourceDecoder::OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo)
{
  MOZ_ASSERT(mReader && !mIsUsingFormatReader);
  GetReader()->OnTrackBufferConfigured(aTrackBuffer, aInfo);
}
Ejemplo n.º 26
0
CXbtManager::XBTFReaders::iterator CXbtManager::GetReader(const CURL& path) const
{
  return GetReader(NormalizePath(path));
}
Ejemplo n.º 27
0
extern "C" DATAREADER_API void GetReaderF(IDataReader<float>** preader)
{
    GetReader(preader);
}
Ejemplo n.º 28
0
bool
MediaSourceDecoder::IsActiveReader(MediaDecoderReader* aReader)
{
  return !mIsUsingFormatReader && GetReader()->IsActiveReader(aReader);
}
Ejemplo n.º 29
0
extern "C" DATAREADER_API void GetReaderD(IDataReader<double>** preader)
{
    GetReader(preader);
}
Ejemplo n.º 30
0
void
MediaSourceDecoder::NotifyTimeRangesChanged()
{
  MOZ_ASSERT(mReader && !mIsUsingFormatReader);
  GetReader()->NotifyTimeRangesChanged();
}