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

📄 pxjpgff.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    }    if (cTmp.GetLength() > 0)    {        HX_DELETE(m_pURL);        m_pURL = new CHXString((const char*) cTmp);    }    // Set the target for the clickthru url    CHXString cTarget;    retVal = ExtractValueString(pValues, "target", "_browser", cTarget);    if (retVal != HXR_OK)    {        HX_RELEASE(pValues);        ReportError(IDS_ERR_JPG_BADTARGET);        return m_pFormatResponse->InitDone(retVal);    }    // Set the reliable flag    retVal = ExtractValueBOOL(pValues, "reliable", FALSE, m_bReliable);    if (retVal != HXR_OK)    {        HX_RELEASE(pValues);        ReportError(IDS_ERR_JPG_BADRELFLAG);        return m_pFormatResponse->InitDone(retVal);    }    // Set the media opacity    HX_RELEASE(m_pMediaOpacityStr);    pValues->GetPropertyCString("mediaOpacity", m_pMediaOpacityStr);    // Set the media chroma key    HX_RELEASE(m_pMediaChromaKeyStr);    pValues->GetPropertyCString("chromaKey", m_pMediaChromaKeyStr);    // Set the media chroma key tolerance    HX_RELEASE(m_pMediaChromaKeyTolStr);    pValues->GetPropertyCString("chromaKeyTolerance", m_pMediaChromaKeyTolStr);    // Set the media chroma key opacity    HX_RELEASE(m_pMediaChromaKeyOpacityStr);    pValues->GetPropertyCString("chromaKeyOpacity", m_pMediaChromaKeyOpacityStr);    // Release the IHXValues object    HX_RELEASE(pValues);    // Check url encoding strings for validity    if (!m_ulBitRate)    {        ReportError(IDS_ERR_JPG_BITRATEZERO);        return m_pFormatResponse->InitDone(HXR_FAIL);    }    if (!m_ulDuration)    {        ReportError(IDS_ERR_JPG_DURATIONZERO);        return m_pFormatResponse->InitDone(HXR_FAIL);    }    if (m_ulDisplayTime >= m_ulDuration)    {        ReportError(IDS_ERR_JPG_DISPTIMETOOBIG);        return m_pFormatResponse->InitDone(HXR_FAIL);    }    if (cTarget == "_player")    {        m_ulTarget = kTargetPlayer;    }    else if (cTarget == "_browser")    {        m_ulTarget = kTargetBrowser;    }    else    {        ReportError(IDS_ERR_JPG_ILLEGALTARGET);        return m_pFormatResponse->InitDone(HXR_FAIL);    }    // Assume default values    m_ulURLType  = kURLTypeNormal;    m_ulSeekTime = 0;    // Check the URL if present    if (m_pURL && m_pURL->GetLength() > 0)    {        // Check to see if it's a command        if (m_pURL->Left(8) == "command:")        {            // Yes it is a command. Make sure it's either seek, pause, or play            if (*m_pURL == "command:pause()")            {                m_ulURLType = kURLTypeCommandPause;            }            else if (*m_pURL == "command:play()")            {                m_ulURLType = kURLTypeCommandPlay;            }            else if (*m_pURL == "command:stop()")            {                m_ulURLType = kURLTypeCommandStop;            }            else if (m_pURL->Mid(8,5) == "seek(" &&                     m_pURL->Right(1) == ")")            {                m_ulURLType = kURLTypeCommandSeek;                // Make sure there's a valid seek time                CHXString cSeekStr   = m_pURL->Mid(13, m_pURL->GetLength() - 14);                BOOL bRet = ConvertTimeStringToULONG32((char*) (const char*) cSeekStr,                                                       cSeekStr.GetLength(),                                                       m_ulSeekTime);                if (bRet == FALSE)                {                    ReportError(IDS_ERR_JPG_BADSEEKTIME);                    return m_pFormatResponse->InitDone(HXR_FAIL);                }            }            else            {                ReportError(IDS_ERR_JPG_UNKPLAYERCOMMAND);                return m_pFormatResponse->InitDone(HXR_FAIL);            }        }    }    // Reconcile the URL and the target    if (m_ulTarget == kTargetBrowser && m_ulURLType != kURLTypeNormal)    {        ReportError(IDS_ERR_JPG_NOTARGETBROWSER);        return m_pFormatResponse->InitDone(HXR_FAIL);    }    // Save a copy of the IHXRequest    m_pRequest = pRequest;    m_pRequest->AddRef();    // Save a copy of the file object    m_pFileObject = pFileObject;    m_pFileObject->AddRef();    // Set the state    m_ulState = kStateFileInitPending;    return m_pFileObject->Init(HX_FILE_READ | HX_FILE_BINARY, this);}STDMETHODIMP CJPEGFileFormat::InitDone(HX_RESULT status){    // Check the state    if (m_ulState != kStateFileInitPending)    {        return HXR_UNEXPECTED;    }    // Get the IHXStat interface from the IHXFileObject    HX_RELEASE(m_pFileStat);    HX_RESULT retVal = m_pFileObject->QueryInterface(IID_IHXFileStat, (void **) &m_pFileStat);    if (retVal != HXR_OK)    {        return m_pFormatResponse->InitDone(retVal);    }    // Set the state    m_ulState = kStateFileStatPending;    // Call IHXStat::Stat()    return m_pFileStat->Stat(this);}STDMETHODIMP CJPEGFileFormat::StatDone(HX_RESULT status,                                       UINT32    ulSize,                                       UINT32    ulCreationTime,                                       UINT32    ulAccessTime,                                       UINT32    ulModificationTime,                                       UINT32    ulMode){    // Check the state    if (m_ulState != kStateFileStatPending)    {        return HXR_UNEXPECTED;    }    // Check the status    if (status != HXR_OK)    {        return m_pFormatResponse->InitDone(status);    }    // Save the file size    m_ulFileSize = ulSize;    // Check the size just to be sure    if (!m_ulFileSize)    {        return m_pFormatResponse->InitDone(HXR_FAIL);    }    // Now we can release the IHXFileStat object    HX_RELEASE(m_pFileStat);    // Go ahead and allocate the file buffer    HX_RELEASE(m_pFileBuffer);    HX_RESULT retVal = m_pClassFactory->CreateInstance(CLSID_IHXBuffer,                                                       (void**) &m_pFileBuffer);    if (SUCCEEDED(retVal))    {        retVal = m_pFileBuffer->SetSize(m_ulFileSize);    }    if (FAILED(retVal))    {        return m_pFormatResponse->InitDone(HXR_FAIL);    }    // Clear the number of bytes read    m_ulBytesRead = 0;    // Set the state    m_ulState = kStateFileReadPending;    // Do a read of the entire file    return m_pFileObject->Read(kReadSize);}STDMETHODIMP CJPEGFileFormat::ReadDone(HX_RESULT status, IHXBuffer *pBuffer){    // Check the state    if (m_ulState != kStateFileReadPending)    {        return HXR_UNEXPECTED;    }    // Check the status    if (status != HXR_OK)    {        return m_pFormatResponse->InitDone(status);    }    // Check for input error    if (!pBuffer)    {        return m_pFormatResponse->InitDone(HXR_FAIL);    }    // Make sure we don't try to copy past the end    // of the file buffer    UINT32 ulBytesToCopy = pBuffer->GetSize();    if (m_ulBytesRead + ulBytesToCopy > m_ulFileSize)    {        ulBytesToCopy = m_ulFileSize - m_ulBytesRead;    }    // Copy the read buffer into the file buffer    memcpy(m_pFileBuffer->GetBuffer() + m_ulBytesRead, /* Flawfinder: ignore */           pBuffer->GetBuffer(),           ulBytesToCopy);    // Update the number of bytes read    m_ulBytesRead += ulBytesToCopy;    // Now if we have not read the whole file, then    // read some more of the file    if (m_ulBytesRead < m_ulFileSize)    {        // Don't have to change the state, since        // we know it's already kStateFilePending        return m_pFileObject->Read(kReadSize);    }    // Now we no longer need the file object    if (m_pFileObject)    {	m_pFileObject->Close();	HX_RELEASE(m_pFileObject);    }    // Here we call the packetization routine    HX_RESULT retVal = ParseImageBuffer(m_pFileBuffer->GetBuffer(), m_ulFileSize);    if (retVal != HXR_OK)    {        HX_RELEASE(m_pFileBuffer);        return m_pFormatResponse->InitDone(retVal);    }    // Set the new state    m_ulState = kStateFileFormatInitialized;    // Now tell the format response we're ready    return m_pFormatResponse->InitDone(HXR_OK);}STDMETHODIMP CJPEGFileFormat::GetFileHeader(){    // Check the state    if (m_ulState != kStateFileFormatInitialized)    {        return HXR_UNEXPECTED;    }    // Get an IHXValues object    IHXValues *pValues = NULL;    HX_RESULT   retVal  = m_pClassFactory->CreateInstance(CLSID_IHXValues, (void **) &pValues);    if (retVal != HXR_OK)    {        return m_pFormatResponse->FileHeaderReady(retVal, NULL);    }    // Set the stream count    retVal = pValues->SetPropertyULONG32("StreamCount", 1);    retVal = pValues->SetPropertyULONG32("IsRealDataType", 1);    if (retVal != HXR_OK)    {        HX_RELEASE(pValues);        return m_pFormatResponse->FileHeaderReady(retVal, NULL);    }    // Set the width and height    pValues->SetPropertyULONG32("Width",  m_ulImageWidth);    pValues->SetPropertyULONG32("Height", m_ulImageHeight);    // Set the new state    m_ulState = kStateFileHeaderSent;    // Call the response interface    retVal = m_pFormatResponse->FileHeaderReady(HXR_OK, pValues);    // Release the reference on the IHXValues object    pValues->Release();        return retVal;}STDMETHODIMP CJPEGFileFormat::GetStreamHeader(UINT16 usStreamNum){    // Check the state    if (m_ulState != kStateFileHeaderSent)    {        return HXR_UNEXPECTED;    }    // Create an IHXValues object    IHXValues *pHeader = NULL;    HX_RESULT retVal = m_pClassFactory->CreateInstance(CLSID_IHXValues, (void **) &pHeader);    if (retVal != HXR_OK)    {        return m_pFormatResponse->StreamHeaderReady(retVal, NULL);    }    // Create mime type IHXBuffer    IHXBuffer *pMimeType = NULL;    retVal = m_pClassFactory->CreateInstance(CLSID_IHXBuffer, (void **) &pMimeType);    if (retVal != HXR_OK)    {        HX_RELEASE(pHeader);        return m_pFormatResponse->StreamHeaderReady(retVal, NULL);    }    // Fill in the mime type    retVal = pMimeType->Set((const BYTE*) m_pszStreamMimeType, strlen(m_pszStreamMimeType) + 1);    if (retVal != HXR_OK)    {        HX_RELEASE(pHeader);        HX_RELEASE(pMimeType);        return m_pFormatResponse->StreamHeaderReady(retVal, NULL);    }    // /Create intrinsicDurationType IHXBuffer:    IHXBuffer* pIntrinsicDurationType = NULL;    retVal = m_pClassFactory->CreateInstance(	    CLSID_IHXBuffer, (void **) &pIntrinsicDurationType);    if (retVal != HXR_OK)    {        HX_RELEASE(pHeader);        HX_RELEASE(pMimeType);        return m_pFormatResponse->StreamHeaderReady(retVal, NULL);    }    // /This is a "discrete" media stream; it has no    // intrinsic (native) duration; we want to continue    // declaring 5000 for the duration, however, since    // we may be serving this stream to an old, SMIL 1.0    // presentation or as a stand-alone play in which the    // author expects the old 5000-msec duration:    retVal = pIntrinsicDurationType->Set((const BYTE*)"intrinsicDurationDiscrete",                                         strlen("intrinsicDurationDiscrete") + 1);    if (retVal != HXR_OK)    {        HX_RELEASE(pHeader);        HX_RELEASE(pMimeType);        HX_RELEASE(pIntrinsicDurationType);        return m_pFormatResponse->StreamHeaderReady(retVal, NULL);    }    // Get the opaque data buffer from the JPEG object

⌨️ 快捷键说明

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