Ejemplo n.º 1
0
void Bwx::ReplaceThrow(const Brx& aBuf)
{
    if (aBuf.Bytes() > MaxBytes()) {
        THROW(BufferOverflow);
    }
    else
    {
        const TByte* dest = Ptr();
        ASSERT(dest != NULL);
        const TByte* src = aBuf.Ptr();
        ASSERT(src != NULL);
        (void)memmove(const_cast<TByte*>(dest), src, aBuf.Bytes());
        iBytes = aBuf.Bytes();
    }
}
Ejemplo n.º 2
0
void OhmSenderDriverWindows::Resend(const Brx& aFrames)
{
    KSPROPERTY prop;
				
	prop.Set = OHSOUNDCARD_GUID;
    prop.Id = KSPROPERTY_OHSOUNDCARD_RESEND;
    prop.Flags = KSPROPERTY_TYPE_SET;

    DWORD returned;

	LPVOID ptr = (LPVOID) aFrames.Ptr();
	DWORD bytes = aFrames.Bytes();

    DeviceIoControl(iHandle, IOCTL_KS_PROPERTY, &prop, sizeof(KSPROPERTY), ptr, bytes, &returned, 0);
}
Ejemplo n.º 3
0
const Brn CommandTokens::GetNextToken(const Brx& aValue, TUint& aIndex)
{
   const TByte* start = aValue.Ptr() + aIndex;
   TUint bytes = aValue.Bytes();
   ASSERT(aIndex <= bytes)

   for (;;)
   {
      if (aIndex == bytes)
      {
         return (Brn(start, 0));
      }

      if (*start != ' ')
      {
         break;
      }

      aIndex++;
      start++;
   }

   const TByte* ptr = start;
   aIndex++;
   ptr++;
   TUint count = 1;

   for (;;)
   {
      if (aIndex == bytes)
      {
         break;
      }

      if (*ptr == ' ')
      {
         break;
      }

      aIndex++;
      ptr++;
      count++;
   }

   return (Brn(start, count));
}
Ejemplo n.º 4
0
TInt Log::Print(FunctorMsg& aOutput, const Brx& aMessage)
{
    TUint remaining = aMessage.Bytes();
    TInt ret = 0;
    const TByte* ptr = aMessage.Ptr();
    while (remaining > 0) {
        TInt len = (remaining<kMaxPrintBytes? remaining : kMaxPrintBytes);
        remaining -= len;
        TChar temp[kMaxPrintBytes+1];
        Bwn msg(temp, len, kMaxPrintBytes+1);
        msg.Replace(ptr, len);
        msg.PtrZ();
        ret += DoPrint(aOutput, msg.Ptr());
        ptr += len;
    }
    return ret;
}
Ejemplo n.º 5
0
void PcmProcessorLe::ProcessFragment24(const Brx& aData, TUint aNumChannels)
{
    TByte *nData;
    TUint  bytes;

    // 24 bit audio is not supported on the platform so it is converted
    // to signed 16 bit audio for playback.
    //
    // Accordingly one third of the input data is discarded.
    bytes = (aData.Bytes() * 2) / 3;

    // If we are manually converting mono to stereo the data will double.
    if (iDuplicateChannel)
    {
        bytes *= 2;
    }

    nData = new TByte[bytes];
    ASSERT(nData != NULL);

    TByte *ptr  = (TByte *)(aData.Ptr() + 0);
    TByte *ptr1 = (TByte *)nData;
    TByte *endp = ptr1 + bytes;

    ASSERT(bytes % 2 == 0);

    while (ptr1 < endp)
    {
        // Store the data in little endian format.
        *ptr1++ = *(ptr+1);
        *ptr1++ = *(ptr+0);

        if (iDuplicateChannel)
        {
            *ptr1++ = *(ptr+1);
            *ptr1++ = *(ptr+0);
        }

        ptr += 3;
    }

    Brn fragment(nData, bytes);
    Flush();
    iSink.Write(fragment);
    delete[] nData;
}
Ejemplo n.º 6
0
void PcmProcessorLe::ProcessFragment8(const Brx& aData, TUint aNumChannels)
{
    TByte *nData;
    TUint  bytes;

    // The input data is converted from unsigned 8 bit to signed 16 bit.
    // to removes poor audio quality and glitches when part of a playlist
    // with tracks of a different bit depth.
    //
    // Accordingly the amount of data is doubled.
    bytes = aData.Bytes() * 2;

    // If we are manually converting mono to stereo the data will double.
    if (iDuplicateChannel)
    {
        bytes *= 2;
    }

    nData = new TByte[bytes];
    ASSERT(nData != NULL);

    TByte *ptr  = (TByte *)(aData.Ptr() + 0);
    TByte *ptr1 = (TByte *)nData;
    TByte *endp = ptr1 + bytes;

    while (ptr1 < endp)
    {
        // Convert U8 to S16 data in little endian format.
        *ptr1++ = 0x00;
        *ptr1++ = *ptr - 0x80;

        if (iDuplicateChannel)
        {
            *ptr1++ = 0x00;
            *ptr1++ = *ptr - 0x80;
        }

        ptr++;
    }

    Brn fragment(nData, bytes);
    Flush();
    iSink.Write(fragment);
    delete[] nData;
}
Ejemplo n.º 7
0
void HeaderSoapAction::Process(const Brx& aValue)
{
    SetReceived();

    // remove quotes if present
    Brn value(aValue);
    TUint bytes = value.Bytes();
    if (bytes >= 2 && value[0] == '\"' && value[bytes - 1] == '\"') {
        value.Set(aValue.Ptr() + 1, bytes - 2);
    }

    Parser parser(value);
    if (parser.Next(':') != Brn("urn")) {
        THROW(HttpError);
    }

    Brn domain = parser.Next(':');
    iDomain.Grow(domain.Bytes() + 10);
    Ssdp::UpnpDomainToCanonical(domain, iDomain);
    if (!iDomain.Bytes()) {
        THROW(HttpError);
    }

    if (parser.Next(':') != Brn("service")) {
        THROW(HttpError);
    }

    iType.Set(parser.Next(':'));
    if (!iType.Bytes()) {
        THROW(HttpError);
    }

    try {
        iVersion = Ascii::Uint(parser.Next('#'));
    }
    catch (AsciiError) { // version not numeric
        THROW(HttpError);
    }

    iAction.Set(Ascii::Trim(parser.Remaining()));
    if (!iAction.Bytes()) {
        THROW(HttpError);
    }
}
Ejemplo n.º 8
0
void Swx::Write(const Brx& aBuffer)
{
    TByte* ptr = Ptr();
    TUint bytes = aBuffer.Bytes();
    if (iBytes + bytes > iMaxBytes) { // would overflow, drain the buffer
        WriteDrain();
        if (bytes > iMaxBytes) { // would still overflow
            try {
                iWriter.Write(aBuffer); // pass it on
                return;
            }
            catch (WriterError&) {
                Error();
            }
        }
    }
    memcpy(ptr + iBytes, aBuffer.Ptr(), bytes);
    iBytes += bytes;
}
Ejemplo n.º 9
0
void PcmProcessorLe::ProcessFragment16(const Brx& aData, TUint aNumChannels)
{
    TByte *nData;
    TUint  bytes;

    bytes = aData.Bytes();

    // If we are manually converting mono to stereo the data will double.
    if (iDuplicateChannel)
    {
        bytes *= 2;
    }

    nData = new TByte[bytes];
    ASSERT(nData != NULL);

    TByte *ptr  = (TByte *)(aData.Ptr() + 0);
    TByte *ptr1 = (TByte *)nData;
    TByte *endp = ptr1 + bytes;

    ASSERT(bytes % 2 == 0);

    while (ptr1 < endp)
    {
        // Store the S16 data in little endian format.
        *ptr1++ = *(ptr+1);
        *ptr1++ = *(ptr);

        if (iDuplicateChannel)
        {
            *ptr1++ = *(ptr+1);
            *ptr1++ = *(ptr);
        }

        ptr +=2;
    }

    Brn fragment(nData, bytes);
    Flush();
    iSink.Write(fragment);
    delete[] nData;
}
Ejemplo n.º 10
0
void OutputProcessorDv::ProcessUint(const Brx& aBuffer, TUint& aVal)
{
    ASSERT(aBuffer.Bytes() == 4);
    (void)memcpy(&aVal, aBuffer.Ptr(), 4);
}
Ejemplo n.º 11
0
void XmlParserBasic::NextTag(const Brx& aDocument, Brn& aName, Brn& aAttributes, Brn& aNamespace, TUint& aIndex, Brn& aRemaining, ETagType& aType)
{
    aName.Set(Brx::Empty());
    aAttributes.Set(Brx::Empty());
    aNamespace.Set(Brx::Empty());
    aRemaining.Set(Brx::Empty());
    Parser parser(aDocument);
    for (;;) {
        Brn item = parser.Next('>');
        TUint bytes = item.Bytes();
        if (bytes > 0 && item[0] != '<') {
            Parser valueParser(item);
            Brn value = valueParser.Next('<');
            bytes -= value.Bytes();
            item.Set(item.Split(value.Bytes(), bytes));
            item.Set(Ascii::Trim(item));
            bytes = item.Bytes();
        }
        if (bytes < 2 || item[0] != '<') {
            THROW(XmlError);
        }
        aIndex = (TUint)(item.Ptr() - aDocument.Ptr());
        if (item[1] == '?') {
            if (bytes < 3) { // catch special case of <?>
                THROW(XmlError);
            }
            if (item[bytes - 1] == '?') { // processing instruction
                continue;
            }
            THROW(XmlError);
        }

        aRemaining.Set(parser.Remaining());

        TUint start = 1; // skip opening '<'
        TUint len = bytes-1;
        if (item[1] == '/') {
            aType = eTagClose;
            start++;
            len--;
        }
        else if (item[bytes-1] == '/') {
            aType = eTagOpenClose;
            len--;
        }
        else {
            aType = eTagOpen;
        }

        parser.Set(item.Split(start, len));
        aName.Set(parser.NextWhiteSpace());
        aAttributes.Set(parser.Remaining());

        if (Ascii::Contains(aName, ':')) { // collect the namespace
            parser.Set(aName);
            aNamespace.Set(parser.Next(':'));
            if (!aNamespace.Bytes()) {
                THROW(XmlError);
            }
            aName.Set(parser.Remaining());
        }
        else {
            aNamespace.Set(Brx::Empty());
        }

        if (!aName.Bytes()) {
            THROW(XmlError);
        }

        return;
    }
}
Ejemplo n.º 12
0
void Bwx::Append(const Brx& aB)
{
    const TByte* ptr = aB.Ptr();
    ASSERT(ptr != NULL);
    Append(ptr, aB.Bytes());
}