⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brushff.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                    IHXBuffer* pASM = NULL;                    retVal = PXUtilities::CreateStringBuffer((const char*) szASM,                                                             m_pContext, pASM);                    if (SUCCEEDED(retVal))                    {                        // Set the properties                        pStreamHeader->SetPropertyULONG32("StreamNumber",          0);                        pStreamHeader->SetPropertyULONG32("MaxBitRate",            kDefaultBitrate);                        pStreamHeader->SetPropertyULONG32("AvgBitRate",            kDefaultBitrate);                        pStreamHeader->SetPropertyULONG32("MaxPacketSize",         kDefaultPacketSize);                        pStreamHeader->SetPropertyULONG32("AvgPacketSize",         kDefaultPacketSize);                        pStreamHeader->SetPropertyULONG32("Preroll",               kDefaultPreroll);                        pStreamHeader->SetPropertyULONG32("Duration",              kDefaultDuration);                        pStreamHeader->SetPropertyCString("MimeType",              pMimeStr);                        pStreamHeader->SetPropertyULONG32("ContentVersion",        m_ulContentVersion);                        pStreamHeader->SetPropertyULONG32("StreamVersion",         m_ulStreamVersion);                        pStreamHeader->SetPropertyCString("ASMRuleBook",           pASM);                        pStreamHeader->SetPropertyCString("intrinsicDurationType", pIntrin);                        if (m_pFileBuffer)                        {                            pStreamHeader->SetPropertyBuffer("OpaqueData", m_pFileBuffer);                        }                        if (m_bNullBrush)                        {                            pStreamHeader->SetPropertyULONG32("NullBrush", 1);                        }                        // Set the new state                        m_ulState = kStateReadyForGetPacket;                        // Pass the stream header back to the server                        m_pFormatResponse->StreamHeaderReady(HXR_OK, pStreamHeader);                    }                    HX_RELEASE(pASM);                }                HX_RELEASE(pIntrin);            }            HX_RELEASE(pMimeStr);        }        HX_RELEASE(pStreamHeader);        // Now we can release the file buffer        HX_RELEASE(m_pFileBuffer);    }    else    {        retVal = HXR_UNEXPECTED;    }    if (FAILED(retVal))    {        m_pFormatResponse->StreamHeaderReady(retVal, NULL);    }    return retVal;}STDMETHODIMP CBrushFileFormat::GetPacket(UINT16 usStreamNum){    HX_RESULT retVal = HXR_OK;    if (m_ulState == kStateReadyForGetPacket)    {        if (usStreamNum == 0)        {            // Set the state            m_ulState = kStateStreamDoneSent;            // Read from the file            m_pFormatResponse->StreamDone(0);        }        else        {            retVal = HXR_INVALID_PARAMETER;        }    }    else    {        retVal = HXR_UNEXPECTED;    }    return retVal;}STDMETHODIMP CBrushFileFormat::Seek(UINT32 ulOffset){    HX_RESULT retVal = HXR_OK;    if (m_pFormatResponse)    {        // Set the state        m_ulState = kStateReadyForGetPacket;        // Tell the format response the seek is done        m_pFormatResponse->SeekDone(HXR_OK);    }    else    {        retVal = HXR_UNEXPECTED;    }    return retVal;}STDMETHODIMP CBrushFileFormat::Close(){    HX_RESULT retVal = HXR_OK;    Deallocate();    return retVal;}STDMETHODIMP CBrushFileFormat::InitDone(HX_RESULT status){    HX_RESULT retVal = HXR_OK;    if (m_ulState == kStateFileInitPending)    {        if (SUCCEEDED(status))        {            // Set the new state            m_ulState = kStateFileReadPending;            // Read the first kDefaultPacketSize bytes of the file            m_pFileObject->Read(kDefaultPacketSize);        }        else        {            // Set the state            m_ulState = kStateError;            // Inform the response interface of the error            m_pFormatResponse->InitDone(status);        }    }    else    {        retVal = HXR_UNEXPECTED;    }    return retVal;}STDMETHODIMP CBrushFileFormat::SeekDone(HX_RESULT status){    return HXR_UNEXPECTED;}STDMETHODIMP CBrushFileFormat::ReadDone(HX_RESULT status, IHXBuffer* pBuffer){    HX_RESULT retVal = HXR_OK;    if (m_ulState == kStateFileReadPending)    {        if (SUCCEEDED(status))        {            // If we already have a buffer, then we'll need to            // copy this buffer into the bigger one. In practical            // use, this should never happen, since the SMIL-generated            // "brush file" should only be a few bytes, well within            // kDefaultPacketSize bytes.            if (m_pFileBuffer)            {                IHXBuffer* pTmp = NULL;                m_pCommonClassFactory->CreateInstance(CLSID_IHXBuffer, (void**) &pTmp);                if (pTmp)                {                    // Set the size                    pTmp->SetSize(m_pFileBuffer->GetSize() + pBuffer->GetSize());                    // Copy in the old buffer                    memcpy(pTmp->GetBuffer(), m_pFileBuffer->GetBuffer(), m_pFileBuffer->GetSize()); /* Flawfinder: ignore */                    // Copy in the new buffer                    memcpy(pTmp->GetBuffer() + m_pFileBuffer->GetSize(), /* Flawfinder: ignore */                           pBuffer->GetBuffer(), pBuffer->GetSize());                    // Now get rid of the old buffer                    HX_RELEASE(m_pFileBuffer);                    m_pFileBuffer = pTmp;                    m_pFileBuffer->AddRef();                }                HX_RELEASE(pTmp);            }            else            {                m_pFileBuffer = pBuffer;                m_pFileBuffer->AddRef();            }            // Set the new state            m_ulState = kStateFileReadPending;            // Read the first kDefaultPacketSize bytes of the file            m_pFileObject->Read(kDefaultPacketSize);        }        else        {            // Set the state            m_ulState = kStateFileClosePending;            // Close the file            m_pFileObject->Close();        }    }    else    {        retVal = HXR_UNEXPECTED;    }    return retVal;}STDMETHODIMP CBrushFileFormat::WriteDone(HX_RESULT status){    // We don't ever write, so we don't expect to get this...    return HXR_UNEXPECTED;}STDMETHODIMP CBrushFileFormat::CloseDone(HX_RESULT status){    HX_RESULT retVal = HXR_OK;    if (m_ulState == kStateFileClosePending)    {        // We can't be initialized successfully if we        // don't have a file buffer        if (!m_pFileBuffer)        {            status = HXR_FAIL;        }        // Set the state        m_ulState = (SUCCEEDED(status) ? kStateFileFormatInitialized : kStateError);        // Send a stream done        m_pFormatResponse->InitDone(status);    }    else    {        retVal = HXR_UNEXPECTED;    }    return retVal;}HX_RESULT STDAPICALLTYPE CBrushFileFormat::HXCreateInstance(IUnknown** ppIUnknown){    HX_RESULT retVal = HXR_FAIL;    if (ppIUnknown)    {        // Create the object        CBrushFileFormat* pObj = new CBrushFileFormat();        if (pObj)        {            // QI for IUnknown            retVal = pObj->QueryInterface(IID_IUnknown, (void**) ppIUnknown);        }    }    return retVal;}HX_RESULT STDAPICALLTYPE CBrushFileFormat::CanUnload2(){    return ((CHXBaseCountingObject::ObjectsActive() > 0) ? HXR_FAIL : HXR_OK );}void CBrushFileFormat::Deallocate(){    HX_RELEASE(m_pContext);    HX_RELEASE(m_pFileObject);    HX_RELEASE(m_pFormatResponse);    HX_RELEASE(m_pCommonClassFactory);    HX_RELEASE(m_pFileBuffer);    Reset();}void CBrushFileFormat::Reset(){    m_pContext            = NULL;    m_pFileObject         = NULL;    m_pFormatResponse     = NULL;    m_pCommonClassFactory = NULL;    m_pFileBuffer         = NULL;    m_ulState             = kStateConstructed;    m_bNullBrush          = FALSE;}BOOL CBrushFileFormat::IsNullBrush(IHXRequest* pRequest){    BOOL bRet = FALSE;    if (pRequest)    {        // Get the request headers        IHXValues* pReqHdrs = NULL;        pRequest->GetRequestHeaders(pReqHdrs);        if (pReqHdrs)        {            // See if there was a "NullBrush" flag            IHXBuffer* pTmp = NULL;            pReqHdrs->GetPropertyCString("NullBrush", pTmp);            if (pTmp)            {                // Yes, there WAS a "NullBrush" flag                bRet = TRUE;            }            HX_RELEASE(pTmp);        }        HX_RELEASE(pReqHdrs);    }    return bRet;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -