nsresult
GMPVideoDecoderParent::Reset()
{
  LOGD(("GMPVideoDecoderParent[%p]::Reset()", this));

  if (!mIsOpen) {
    NS_WARNING("Trying to use an dead GMP video decoder");
    return NS_ERROR_FAILURE;
  }

  MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());

  if (!SendReset()) {
    return NS_ERROR_FAILURE;
  }

  mIsAwaitingResetComplete = true;

  RefPtr<GMPVideoDecoderParent> self(this);
  nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([self]() -> void
  {
    LOGD(("GMPVideoDecoderParent[%p]::ResetCompleteTimeout() timed out waiting for ResetComplete", self.get()));
    self->mResetCompleteTimeout = nullptr;
    LogToBrowserConsole(NS_LITERAL_STRING("GMPVideoDecoderParent timed out waiting for ResetComplete()"));
  });
  CancelResetCompleteTimeout();
  mResetCompleteTimeout = SimpleTimer::Create(task, 5000, mPlugin->GMPThread());

  // Async IPC, we don't have access to a return value.
  return NS_OK;
}
nsresult
GMPAudioDecoderParent::Reset()
{
  if (!mIsOpen) {
    NS_WARNING("Trying to use a dead GMP Audio decoder!");
    return NS_ERROR_FAILURE;
  }

  MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());

  if (!SendReset()) {
    return NS_ERROR_FAILURE;
  }

  // Async IPC, we don't have access to a return value.
  return NS_OK;
}
nsresult
GMPVideoDecoderParent::Reset()
{
  if (!mCanSendMessages) {
    NS_WARNING("Trying to use an invalid GMP video decoder!");
    return NS_ERROR_FAILURE;
  }

  MOZ_ASSERT(mPlugin->GMPThread() == NS_GetCurrentThread());

  if (!SendReset()) {
    return NS_ERROR_FAILURE;
  }

  // Async IPC, we don't have access to a return value.
  return NS_OK;
}
示例#4
0
LRESULT CBTTestDlg::OnInitialise(WPARAM wParam, LPARAM lParam)
{
	// Start listening for HCI events from the HW
	if (StartEventListener()!=ERROR_SUCCESS)
	{
		MessageBox(_T("Failed to start HCI Event Listener!"));
		exit(0);

	}

	// Send a reset command and wait for it to complete
	SendReset();

	// Wait a bit to make sure the device is ready...
	Sleep(1000);

	FBT_HCI_READ_LOCAL_VERSION_INFORMATION_COMPLETE CommandComplete;
	if (FBT_HCI_SUCCESS(SendReadLocalVersionInformation(CommandComplete)))
	{
		fbtLog(fbtLog_Notice, "HCI Version=%d, HCI Revsion=%d, LMP Version=%d, LMP SubVersion=%d, Manufacturer=%s",
			CommandComplete.HCIVersion,
			CommandComplete.HCIRevision,
			CommandComplete.LMPVersion,
			CommandComplete.LMPSubVersion,
			GetManufacturerName(CommandComplete.Manufacturer));

		m_stManufacturer.SetWindowText(GetManufacturerName(CommandComplete.Manufacturer));

		CString szTemp;
		szTemp.Format("%d, %d", CommandComplete.HCIVersion, CommandComplete.HCIRevision);
		m_stHCIVersion.SetWindowText(szTemp);

		szTemp.Format("%d, %d", CommandComplete.LMPVersion, CommandComplete.LMPSubVersion);
		m_stLMPVersion.SetWindowText(szTemp);

	}

	// Make the device discoverable
	SendWriteScanEnable(3);

	// Set default connect timeout
	SendWritePageTimeout(0x2000);

	// Set the the class of device
	BYTE ClassOfDeviceBytes[FBT_HCI_DEVICE_CLASS_SIZE]={0};

	// PC
	ClassOfDeviceBytes[0]=0x10;
	ClassOfDeviceBytes[1]=0x01;
	ClassOfDeviceBytes[2]=0x02;

	fbtLog(fbtLog_Notice, _T("CBTTestDlg::OnInitDialog: Calling SendWriteClassOfDevice"));
	SendWriteClassOfDevice(ClassOfDeviceBytes);

	fbtLog(fbtLog_Notice, _T("CBTTestDlg::OnInitDialog: Calling SendSetEventFilter"));

	// Enable connection auto-accept
	BYTE Condition[FBT_HCI_MAX_CONDITION_SIZE]={0};
	Condition[0]=2;
	SendSetEventFilter(
		FBT_HCI_FILTER_CONNECTION_SETUP,
		FBT_HCI_FILTER_ALL,
		Condition,
		1);

	// Set the Device Name
	TCHAR szDeviceName[80]={0};
	ZeroMemory(szDeviceName, 80);
	DWORD dwLength=80;
	if (GetComputerName(szDeviceName, &dwLength))
	{
		BYTE szLocalName[FBT_HCI_NAME_SIZE]={0};
		strcpy((char*)szLocalName, szDeviceName);
		SendChangeLocalName(szLocalName);

	}

	// Read the local BD_ADDR
	BYTE BD_ADDR[FBT_HCI_BDADDR_SIZE];
	if (ReadBDADDR(BD_ADDR)==ERROR_SUCCESS)
	{
		CString szDevice;
		szDevice.Format(_T("%02X:%02X:%02X:%02X:%02X:%02X"),
							BD_ADDR[5],
							BD_ADDR[4],
							BD_ADDR[3],
							BD_ADDR[2],
							BD_ADDR[1],
							BD_ADDR[0]);

		m_stAddress.SetWindowText(szDevice);

	}

	else
		fbtLog(fbtLog_Notice, _T("CBTTestDlg::OnInitDialog: Failed to read BDADDR"));

	// Start the reader thread
	HANDLE hThread = CreateThread( NULL, 0, Reader, (LPVOID)this, 0, NULL );
   CloseHandle( hThread );

	return TRUE;

}
示例#5
0
void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
    Header responseHeader;
    Header requestHeader;
    RequestMetadata requestMetadata;
    Message *message = NULL;
    ThreadError error;

    SuccessOrExit(error = responseHeader.FromMessage(aMessage));
    aMessage.MoveOffset(responseHeader.GetLength());

    message = FindRelatedRequest(responseHeader, aMessageInfo, requestHeader, requestMetadata);

    if (message == NULL)
    {
        ExitNow();
    }

    switch (responseHeader.GetType())
    {
    case kCoapTypeReset:
        if (responseHeader.IsEmpty())
        {
            FinalizeCoapTransaction(*message, requestMetadata, NULL, NULL, kThreadError_Abort);
        }

        // Silently ignore non-empty reset messages (RFC 7252, p. 4.2).
        break;

    case kCoapTypeAcknowledgment:
        if (responseHeader.IsEmpty())
        {
            // Empty acknowledgment.
            if (requestMetadata.mConfirmable)
            {
                requestMetadata.mAcknowledged = true;
                requestMetadata.UpdateIn(*message);
            }

            // Remove the message if response is not expected, otherwise await response.
            if (requestMetadata.mResponseHandler == NULL)
            {
                DequeueMessage(*message);
            }
        }
        else if (responseHeader.IsResponse() && responseHeader.IsTokenEqual(requestHeader))
        {
            // Piggybacked response.
            FinalizeCoapTransaction(*message, requestMetadata, &responseHeader, &aMessage, kThreadError_None);
        }

        // Silently ignore acknowledgments carrying requests (RFC 7252, p. 4.2)
        // or with no token match (RFC 7252, p. 5.3.2)
        break;

    case kCoapTypeConfirmable:
    case kCoapTypeNonConfirmable:
        if (responseHeader.IsConfirmable())
        {
            // Send empty ACK if it is a CON message.
            SendEmptyAck(aMessageInfo.GetPeerAddr(), aMessageInfo.mPeerPort, responseHeader.GetMessageId());
        }

        FinalizeCoapTransaction(*message, requestMetadata, &responseHeader, &aMessage, kThreadError_None);

        break;
    }

exit:

    if (error == kThreadError_None && message == NULL)
    {
        if (responseHeader.IsConfirmable() || responseHeader.IsNonConfirmable())
        {
            // Successfully parsed a header but no matching request was found - reject the message by sending reset.
            SendReset(aMessageInfo.GetPeerAddr(), aMessageInfo.mPeerPort, responseHeader.GetMessageId());
        }
    }
}
bool CSMTPClientInstance::SendRelayMessageFromFile( const char *pszFileName )
{
	// Check mode
	if ( m_state != STATE_DOMAIL )
	{
		if ( m_state == STATE_DOHELO )
		{
			SendHelo();
		}
		else
		{
			// It is in MAIL somewhere... send reset
			SendReset();
		}
	}

	// Now check state
	if ( m_state != STATE_DOMAIL )
	{
		m_state = STATE_ERROR;
		return false;
	}

	// Open file for relay...
	FILE *pFile = fopen( pszFileName, "r" );

	if ( !pFile )
	{
		m_state = STATE_ERROR;
		return false;
	}

	CIOFileConnection oFileConnection;

	oFileConnection.SetFile( pFile );

	for (;;)
	{

		// Now read in the file and send it
		char szLineBuffer[1024];
		char szResponseMessage[1024];
		uint32_t readLen = 0;
		uint32_t responseCode = 0;

		// Read in a line and send it
		readLen = oFileConnection.ReadLine( (uint8_t*)szLineBuffer, 1024 );

		if ( readLen == 0 )
			break;

		m_pIOConnection->WriteLine( (uint8_t*)szLineBuffer, readLen );

		// Now read response
		m_pIOConnection->ReadLine( (uint8_t*)szLineBuffer, 1024 );

		// Parse response
		sscanf( szLineBuffer, "%d %s\r\n", &responseCode, szResponseMessage );

		if ( responseCode == 354 )
			break;

		if ( responseCode != 250 )
		{
			m_state = STATE_ERROR;
			SendReset();
			return false;
		}
	}

	// DATA MODE
	for (;;)
	{
		// Now read in the file and send it
		char szLineBuffer[1024];
		uint32_t readLen = 0;

		// Read in a line and send it
		readLen = oFileConnection.ReadLine( (uint8_t*)szLineBuffer, 1024 );

		if ( readLen == 0 )
			break;

		m_pIOConnection->WriteLine( (uint8_t*)szLineBuffer, readLen );
	}

	// Close the file
	fclose( pFile );

	// Now read the response
	{
		char szLineBuffer[1024];
		char szResponseMessage[1024];
		uint32_t readLen = 0;
		uint32_t responseCode = 0;

		// Now read response
		m_pIOConnection->ReadLine( (uint8_t*)szLineBuffer, 1024 );

		// Parse response
		sscanf( szLineBuffer, "%d %s\r\n", &responseCode, szResponseMessage );

		if ( responseCode != 250 )
		{
			m_state = STATE_ERROR;
			SendReset();
			return false;
		}

	}

	return true;
}