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

📄 pxjpgff.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: pxjpgff.cpp,v 1.3.24.1 2004/07/09 01:53:35 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 <stdio.h>#include <string.h>#include <stdlib.h> // for atol#include <ctype.h>  // for toupper// From include#include "hxcom.h"#include "hxtypes.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxformt.h"#include "hxplugn.h"#include "hxpends.h"#include "hxasm.h"#include "hxerror.h"#include "hxver.h"#include "hxxres.h"#include "hxxrsmg.h"#include "hxvsrc.h"  /*IHXFileViewSource*/#include "ihxfgbuf.h"#include "hxengin.h"// From pncont#include "chxpckts.h"#include "hxstring.h"#include "hxslist.h"// From pnmisc#include "hxurl.h"#include "unkimp.h"#include "baseobj.h"// From pxcomlib#include "pxcolor.h"#include "parseurl.h"#include "pxutil.h"// From coreres#include "pixres.h"#include "jpegvsrc.h"#include "pxjpgff.h"#include "jpgfformat.ver"// pndebug#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE		static char HX_THIS_FILE[] = __FILE__;#endif#define BASE_JPEGSTREAM_VERSION    HX_ENCODE_PROD_VERSION(0, 0, 0, 0)#define OPACITY_JPEGSTREAM_VERSION HX_ENCODE_PROD_VERSION(0, 1, 0, 0)const UINT32 CJPEGFileFormat::m_ulContentVersion     = HX_ENCODE_PROD_VERSION(0, 0, 0, 0);const UINT32 CJPEGFileFormat::m_ulStreamVersion      = BASE_JPEGSTREAM_VERSION;const char * const CJPEGFileFormat::m_pszDescription       = "Helix JPEG File Format Plugin";const char * const CJPEGFileFormat::m_pszCopyright         = HXVER_COPYRIGHT;const char * const CJPEGFileFormat::m_pszMoreInfoURL       = HXVER_MOREINFO;const char * const CJPEGFileFormat::m_ppszFileMimeTypes[]  = {"image/jpeg", NULL};const char * const CJPEGFileFormat::m_ppszFileExtensions[] = {"jpg", "jpeg", "jpe", "jfif", NULL};const char * const CJPEGFileFormat::m_ppszFileOpenNames[]  = {"JPEG Images (*.jpg)", NULL};const char * const CJPEGFileFormat::m_pszStreamMimeType    = "application/vnd.rn-jpegstream";#ifdef _WINDOWSextern HINSTANCE g_hInstance;#endifCJPEGFileFormat::CJPEGFileFormat(){    m_lRefCount                 = 0;    m_pContext                  = NULL;    m_pFileObject               = NULL;    m_pFormatResponse           = NULL;    m_pClassFactory             = NULL;    m_ulState                   = kStateConstructed;    m_pRequest                  = NULL;    m_pError                    = NULL;    m_pFileStat                 = NULL;    m_ulFileSize                = 0;    m_pFileBuffer               = NULL;    m_pPacketInfoList           = NULL;    m_pPacketInfoListItr        = NULL;    m_ulRestartInterval         = 0;    m_ulImageWidth              = 0;    m_ulImageHeight             = 0;    m_ulBitRate                 = 0;    m_ulPreroll                 = 0;    m_ulMaxPacketSize           = 0;    m_ulMinPacketSize           = 0;    m_ulAvgPacketSize           = 0;    m_ulTotalBytesToSend        = 0;    m_ulDuration                = 0;    m_lCurrentTimeStamp         = 0;    m_ulDisplayTime             = 0;    m_pURL                      = NULL;    m_ulTarget                  = kTargetBrowser;    m_ulURLType                 = kURLTypeNormal;    m_ulSeekTime                = 0;    m_bReliable                 = FALSE;    m_pMediaOpacityStr          = NULL;    m_pMediaChromaKeyStr        = NULL;    m_pMediaChromaKeyTolStr     = NULL;    m_pMediaChromaKeyOpacityStr = NULL;    m_ulBytesRead               = 0;};CJPEGFileFormat::~CJPEGFileFormat(){    Close();};    STDMETHODIMP CJPEGFileFormat::QueryInterface(REFIID riid, void **ppvObj){    if (IsEqualIID(riid, IID_IUnknown))    {        AddRef();        *ppvObj = (IUnknown *) (IHXPlugin *) this;        return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXPlugin))    {        AddRef();        *ppvObj = (IHXPlugin *) this;        return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXFileFormatObject))    {        AddRef();        *ppvObj = (IHXFileFormatObject *) this;        return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXFileResponse))    {        AddRef();        *ppvObj = (IHXFileResponse *) this;        return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXBackChannel))    {        AddRef();        *ppvObj = (IHXBackChannel *) this;        return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXASMSource))    {        AddRef();        *ppvObj = (IHXASMSource *) this;        return HXR_OK;    }    else if (IsEqualIID(riid, IID_IHXFileViewSource))    {	CJPEGViewSource* pVsrc = new CJPEGViewSource(m_pContext,		(IUnknown*)(IHXPlugin*)this);	if ( pVsrc == NULL )	{	    return HXR_FAIL;	}	return pVsrc->QueryInterface(riid, ppvObj);    }    else if (IsEqualIID(riid, IID_IHXThreadSafeMethods))    {	AddRef();	*ppvObj = (IHXThreadSafeMethods*)this;	return HXR_OK;    }        *ppvObj = NULL;    return HXR_NOINTERFACE;}STDMETHODIMP_(UINT32) CJPEGFileFormat::AddRef(){    return InterlockedIncrement(&m_lRefCount);}STDMETHODIMP_(UINT32) CJPEGFileFormat::Release(){    if (InterlockedDecrement(&m_lRefCount) > 0)    {        return m_lRefCount;    }    delete this;    return 0;}STDMETHODIMP CJPEGFileFormat::GetPluginInfo(REF(BOOL)         rbLoadMultiple,                                            REF(const char *) rpszDescription,                                            REF(const char *) rpszCopyright,                                            REF(const char *) rpszMoreInfoURL,                                            REF(UINT32)       rulVersionNumber){    rbLoadMultiple   = TRUE;    rpszDescription  = m_pszDescription;    rpszCopyright    = m_pszCopyright;    rpszMoreInfoURL  = m_pszMoreInfoURL;    rulVersionNumber = TARVER_ULONG32_VERSION;    return HXR_OK;}STDMETHODIMP CJPEGFileFormat::InitPlugin(IUnknown *pContext){    // Check for input error    if (!pContext)    {        return HXR_FAIL;    }    // Save a copy of the calling context    m_pContext = pContext;    m_pContext->AddRef();    // Get an interface to the common class factory    HX_RELEASE(m_pClassFactory);    HX_RESULT retVal = m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void **) &m_pClassFactory);    if (retVal != HXR_OK)    {        HX_RELEASE(m_pContext);        return retVal;    }    // Get the IHXErrorMessages interface - it's OK if TLC doesn't support it    HX_RELEASE(m_pError);    m_pContext->QueryInterface(IID_IHXErrorMessages, (void **) &m_pError);    // Set the state    m_ulState = kStatePluginInitialized;    return HXR_OK;}STDMETHODIMP CJPEGFileFormat::GetFileFormatInfo(REF(const char **) rppszFileMimeTypes,                                                REF(const char **) rppszFileExtensions,                                                  REF(const char **) rppszFileOpenNames){    rppszFileMimeTypes  = (const char **) m_ppszFileMimeTypes;    rppszFileExtensions = (const char **) m_ppszFileExtensions;    rppszFileOpenNames  = (const char **) m_ppszFileOpenNames;    return HXR_OK;}STDMETHODIMP CJPEGFileFormat::InitFileFormat(IHXRequest        *pRequest,                                              IHXFormatResponse *pFormatResponse,                                             IHXFileObject     *pFileObject){    // Check for input error    if (!pFormatResponse)    {        return HXR_FAIL;    }    if (!pRequest || !pFileObject)    {        return pFormatResponse->InitDone(HXR_FAIL);    }    // Save a copy of the format response    m_pFormatResponse = pFormatResponse;    m_pFormatResponse->AddRef();     // Create an IHXValues object to hold the param name/value pairs    IHXValues *pValues = NULL;    HX_RESULT retVal = m_pClassFactory->CreateInstance(CLSID_IHXValues,                                                       (void**) &pValues);    if (FAILED(retVal))    {        return m_pFormatResponse->InitDone(retVal);    }    // Now add the following parameters to the IHXValues. These    // parameters could have come as URL-encoded parameters or as    // parameters in the request headers. These parameters will be    // added as CString properties to the IHXValues.    AddURLOrRequestParam(pRequest, "bitrate",     m_pContext, pValues);    AddURLOrRequestParam(pRequest, "preroll",     m_pContext, pValues);    AddURLOrRequestParam(pRequest, "duration",    m_pContext, pValues);    AddURLOrRequestParam(pRequest, "displaytime", m_pContext, pValues);    AddURLOrRequestParam(pRequest, "url",         m_pContext, pValues);    AddURLOrRequestParam(pRequest, "target",      m_pContext, pValues);    AddURLOrRequestParam(pRequest, "reliable",    m_pContext, pValues);    AddURLOrRequestParam(pRequest, "mediaOpacity",       m_pContext, pValues);    AddURLOrRequestParam(pRequest, "chromaKey",          m_pContext, pValues);    AddURLOrRequestParam(pRequest, "chromaKeyTolerance", m_pContext, pValues);    AddURLOrRequestParam(pRequest, "chromaKeyOpacity",   m_pContext, pValues);    // Set the bitrate    retVal = ExtractValueUINT32(pValues, "bitrate", kDefaultBitRate, m_ulBitRate);    if (retVal != HXR_OK)    {        HX_RELEASE(pValues);        ReportError(IDS_ERR_JPG_BADBITRATE);        return m_pFormatResponse->InitDone(retVal);    }    // Set the preroll    retVal = ExtractValueTime(pValues, "preroll", 0, m_ulPreroll);    if (retVal != HXR_OK)    {        HX_RELEASE(pValues);        ReportError(IDS_ERR_JPG_BADPREROLL);        return m_pFormatResponse->InitDone(retVal);    }    // Set the duration    retVal = ExtractValueTime(pValues, "duration", kDefaultDuration, m_ulDuration);    if (retVal != HXR_OK)    {        HX_RELEASE(pValues);        ReportError(IDS_ERR_JPG_BADDURATION);        return m_pFormatResponse->InitDone(retVal);    }    // Set the display time    retVal = ExtractValueTime(pValues, "displaytime", kDefaultDisplayTime, m_ulDisplayTime);    if (retVal != HXR_OK)    {        HX_RELEASE(pValues);        ReportError(IDS_ERR_JPG_BADDISPLAYTIME);        return m_pFormatResponse->InitDone(retVal);    }    // Set the clickthru url    CHXString cTmp;    retVal = ExtractValueString(pValues, "url", NULL, cTmp);    if (retVal != HXR_OK)    {        HX_RELEASE(pValues);        ReportError(IDS_ERR_JPG_BADURL);        return m_pFormatResponse->InitDone(retVal);

⌨️ 快捷键说明

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