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

📄 pxjpgrnd.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: pxjpgrnd.cpp,v 1.4.22.1 2004/07/09 01:53:52 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** */// include#include "hxtypes.h"#include "hxwintyp.h"#include "hxcom.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxcore.h"#include "hxrendr.h"#include "hxhyper.h"#include "hxplugn.h"#include "hxwin.h"#include "hxasm.h"#include "hxevent.h"#include "hxvsurf.h"#include "hxver.h"#include "hxupgrd.h"#include "hxengin.h"#include "hxmon.h"#include "hxprefs.h"#include "hxerror.h"// pncont#include "hxbuffer.h"#include "hxstring.h"// pnmisc#include "unkimp.h"#include "baseobj.h"#ifdef _AIX#include "dllpath.h"ENABLE_MULTILOAD_DLLACCESS_PATHS(Pxjpgrnd);#endif// baserend#include "baserend.h"#include "vbasernd.h"// pxcomlib#include "glist.h"#include "gstring.h"#include "pxutil.h"#include "pxcolor.h"#include "parseurl.h"#include "pxtransp.h"// jpeglib#include "ijglwrap.h"// pxjpgrnd#include "gimage.h"#include "pxjpmlog.h"#include "pxjpgrnd.h"#include "jpgrender.ver"// pndebug#include "errdbg.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE		static char HX_THIS_FILE[] = __FILE__;#endifconst char* const CJPEGRenderer::m_pszName        = "JPEG";const char* const CJPEGRenderer::m_pszDescription = "Helix JPEG Renderer Plugin";const char* const CJPEGRenderer::m_ppszMimeType[] = {"application/vnd.rn-jpegstream", NULL};CJPEGRenderer::CJPEGRenderer() : CRNVisualBaseRenderer(){    MLOG_LEAK("0x%08x:CJPEGRenderer::CJPEGRenderer()\n", this);    m_ulImageWidth              = 0;    m_ulImageHeight             = 0;    m_pDecomp                   = NULL;    m_pImage                    = NULL;    m_bFirstPacket              = FALSE;    m_lTimeOffset               = 0;    m_ulTotalPackets            = 0;    m_ulNumPackets              = 0;    m_bValidImage               = FALSE;    m_ulTarget                  = kTargetBrowser;    m_pURL                      = NULL;    m_ulDisplayTime             = 0;    m_bPastDisplayTime          = FALSE;    m_ulMediaOpacity            = 255;    m_bMediaOpacitySpecified    = FALSE;    m_ulMediaChromaKey          = 0;    m_bMediaChromaKeySpecified  = FALSE;    m_ulMediaChromaKeyTolerance = 0;    m_ulMediaChromaKeyOpacity   = 0;    m_bUsesAlphaChannel         = FALSE;    m_bPendingTransparencyBlt   = FALSE;}CJPEGRenderer::~CJPEGRenderer(){    MLOG_LEAK("0x%08x:CJPEGRenderer::~CJPEGRenderer()\n", this);    HX_DELETE(m_pDecomp);    HX_RELEASE(m_pImage);    HX_DELETE(m_pURL);}STDMETHODIMP CJPEGRenderer::QueryInterface(REFIID riid, void** ppvObj){    // If we ever have any new interfaces to add which    // are specific to the jpeg renderer, then we'll need    // to add them here. Until then we simply proxy the    // visual base renderer.    return CRNVisualBaseRenderer::QueryInterface(riid, ppvObj);}STDMETHODIMP_(UINT32) CJPEGRenderer::AddRef(){    return CRNVisualBaseRenderer::AddRef();}STDMETHODIMP_(UINT32) CJPEGRenderer::Release(){    return CRNVisualBaseRenderer::Release();}STDMETHODIMP CJPEGRenderer::OnHeader(IHXValues *pHeader){    // Check for input error    if (!pHeader)    {        return HXR_FAIL;    }    // Check presentation stream and content versions    HX_RESULT retVal = CheckStreamVersions(pHeader); // XXXMEH - base renderer    if (FAILED(retVal))    {        AddMimeToUpgradeCollection(m_ppszMimeType[0]); // XXXMEH - base renderer        return HXR_FAIL;    }    // Get the opaque data buffer    IHXBuffer *pOpaqueData = NULL;    retVal                  = pHeader->GetPropertyBuffer("OpaqueData", pOpaqueData);    if (FAILED(retVal))    {        return HXR_FAIL;    }    // Check for the minimal size    if (pOpaqueData->GetSize() < 16)    {        HX_RELEASE(pOpaqueData);        return HXR_FAIL;    }    // Pull out the width, height, and file size from the opaque data    BYTE *pData = pOpaqueData->GetBuffer();    BYTE  ucTmp;    UnPack32(pData, m_ulImageWidth);    UnPack32(pData, m_ulImageHeight);    UnPack32(pData, m_ulTotalPackets);    UnPack32(pData, m_ulDisplayTime);    UnPack8(pData,  ucTmp);    m_ulTarget  = ucTmp;    // These are no longer used by the renderer they are parsed in the new hypernavigate object in the core so all renderer    // commands are consistent and parsed in one place.  We do have to skip over them since the file format still puts them in.//  UnPack8(pData,  ucTmp);//  UnPack32(pData, m_ulSeekTime);    pData += 5;// Even though the 2 above members were removed we still need to increment the data pointer    UINT16 usLen;    UnPack16(pData, usLen);    if (usLen)    {        HX_DELETE(m_pURL);        m_pURL = new CHXString((const char*) pData, (int) usLen);        if (!m_pURL)        {            HX_RELEASE(pOpaqueData);            return HXR_FAIL;        }    }    // Release our ref on the opaque data buffer    HX_RELEASE(pOpaqueData);    // Check for error in the opaque data    if (!m_ulImageWidth || !m_ulImageHeight)    {            return HXR_FAIL;    }    // Get the current URL    IHXStreamSource* pStreamSource = NULL;    retVal = m_pStream->GetSource(pStreamSource);    if (FAILED(retVal))    {        return HXR_FAIL;    }    const char* pszURL = pStreamSource->GetURL();    if (!pszURL)    {        HX_RELEASE(pStreamSource);        return HXR_FAIL;    }    CHXString cOriginalURL = pszURL;    HX_RELEASE(pStreamSource);    // Check the URL to see if it's relative    if (m_pURL)    {        if (m_pURL->GetLength() > 0)        {            if (m_ulTarget == kTargetPlayer)            {                if (IsURLRelative((const char*) *m_pURL) &&                    !strstr((const char*) *m_pURL, "command:"))                {                    CHXString cAbsURL;                    retVal = MakeAbsoluteURL(cOriginalURL, *m_pURL, cAbsURL);                    if (SUCCEEDED(retVal))                    {                        *m_pURL = cAbsURL;                    }                }            }        }    }    // Allocate a IJG library wrapper    HX_DELETE(m_pDecomp);    m_pDecomp = new CIJGLibraryWrapper();    if (!m_pDecomp)    {        return HXR_OUTOFMEMORY;    }    // Initialize the library wrapper    retVal = m_pDecomp->Initialize();    if (FAILED(retVal))    {        HX_DELETE(m_pDecomp);        return retVal;    }    // Get the transparency parameters from the stream header    UINT32 ulDummy  = 0;    BOOL   bDummy   = FALSE;    BOOL   bMedOp   = m_bMediaOpacitySpecified;    BOOL   bMedCK   = m_bMediaChromaKeySpecified;    BOOL   bUseAlph = m_bUsesAlphaChannel;    ParseTransparencyParameters(pHeader, ulDummy, bDummy,                                m_ulMediaOpacity,                                bMedOp,                                m_ulMediaChromaKey,                                bMedCK,                                m_ulMediaChromaKeyTolerance,                                m_ulMediaChromaKeyOpacity,                                bUseAlph);    m_bMediaOpacitySpecified   = bMedOp;    m_bMediaChromaKeySpecified = bMedCK;    m_bUsesAlphaChannel        = bUseAlph;    // Set these transparency parameters into the decoding object    if (m_bMediaOpacitySpecified)    {        m_pDecomp->SetOpacity(m_ulMediaOpacity);    }    if (m_bMediaChromaKeySpecified)    {        m_pDecomp->SetChromaKeyInfo(m_ulMediaChromaKey,                                    m_ulMediaChromaKeyTolerance,                                    m_ulMediaChromaKeyOpacity);    }    // Set the flag saying we're expecting the first packet    m_bFirstPacket = TRUE;    // Initialize the number of packets we've received    m_ulNumPackets     = 0;    m_bValidImage      = FALSE;    m_bPastDisplayTime = FALSE;    // Set the media opacity - CRNBaseRenderer (our grandparent    // class) supports IHXValues    SetPropertyULONG32("mediaOpacity", m_ulMediaOpacity);    MLOG_MISC(m_pErrorMessages,              "0x%08x:CJPEGRenderer::OnHeader()\n"              "\tWidth=%lu\n"              "\tHeight=%lu\n"              "\tTotalPackets=%lu\n"              "\tDisplayTime=%lu\n",              this, m_ulImageWidth, m_ulImageHeight,              m_ulTotalPackets, m_ulDisplayTime);    return HXR_OK;}STDMETHODIMP CJPEGRenderer::OnPacketNoOffset(IHXPacket *pPacket){    MLOG_MISC(m_pErrorMessages,              "0x%08x:CJPEGRenderer::OnPacketNoOffset() Packet %lu of %lu\n",              this, m_ulNumPackets, m_ulTotalPackets);    // Check for input error    if (!pPacket)    {        return HXR_FAIL;    }    // Increment the number of packets    m_ulNumPackets++;    // If the packet is lost, we're done    if (pPacket->IsLost())    {        if (m_ulNumPackets >= m_ulTotalPackets)        {            m_bValidImage = TRUE;        }        return HXR_OK;    }    // Get the buffer    IHXBuffer *pBuffer = pPacket->GetBuffer();    if (!pBuffer)    {        return HXR_FAIL;    }    // Is this the first packet    HX_RESULT retVal;    if (m_bFirstPacket)    {        // Clear the flag        m_bFirstPacket = FALSE;        // This packet should be a header packet        BYTE *pData = pBuffer->GetBuffer() + 8;        UINT32 ulSequenceNumber;        UnPack32(pData, ulSequenceNumber);        BOOL   bLost = (ulSequenceNumber == 0 ? FALSE : TRUE);        if (bLost == TRUE)        {            // Set the wrapper flag to false - preventing use of any further packets            m_pDecomp->SetValid(FALSE);            HX_RELEASE(pBuffer);            return HXR_OK;        }        // Initialize the last sequence number        m_pDecomp->SetLastSequenceNumber(0);        // Go ahead and add this buffer to the list        m_pDecomp->AppendBuffer(pBuffer);        // Release our reference on this buffer, since adding it to the list ref's it        HX_RELEASE(pBuffer);        // Set this flag so we won't add this packet's buffer twice        m_pDecomp->SetNeedPacket(FALSE);        // Create an IHXValues object        IHXValues *pDecompValues = NULL;        retVal = m_pCommonClassFactory->CreateInstance(CLSID_IHXValues, (void **) &pDecompValues);

⌨️ 快捷键说明

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