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

📄 wirefmgr.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: wirefmgr.cpp,v 1.2.24.1 2004/07/09 01:54:51 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 "hxresult.h"#include "hxcom.h"#include "ihxpckts.h"#include "hxvsurf.h"#include "hxfiles.h"#include "hxcomm.h"#include "hxerror.h"// hxmisc#include "unkimp.h"#include "baseobj.h"// hxcont#include "hxstring.h"#include "hxslist.h"#include "hxmap.h"// pxcomlib#include "pxrect.h"#include "pxcolor.h"#include "pxeffect.h"#include "hxslist.h"#include "hxmap.h"#include "gstring.h"#include "pxutil.h"#include "nestbuff.h"#include "wirefmgr.h"// hxdebug#include "errdbg.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE     static char HX_THIS_FILE[] = __FILE__;#endif#define BASE_STREAM_VERSION      HX_ENCODE_PROD_VERSION(0, 0, 0, 0)#define U2_STREAM_VERSION        HX_ENCODE_PROD_VERSION(1, 1, 0, 0)#define COOKIE_STREAM_VERSION    HX_ENCODE_PROD_VERSION(1, 2, 0, 0)#define CACHINGAD_STREAM_VERSION HX_ENCODE_PROD_VERSION(1, 3, 0, 0)#define OPACITY_STREAM_VERSION   HX_ENCODE_PROD_VERSION(1, 4, 0, 0)const UINT32 PXWireFormatManager::m_ulHighestSupportedStreamVersion = OPACITY_STREAM_VERSION;PXWireFormatManager::PXWireFormatManager(){    Reset();    m_lRefCount            = 0;    m_pContext             = NULL;    m_pCommonClassFactory  = NULL;    m_pTitleStr            = NULL;    m_pAuthorStr           = NULL;    m_pCopyrightStr        = NULL;    m_pDefaultURLStr       = NULL;    m_pCodecMimeList       = NULL;    m_pFXPackageMimeList   = NULL;    m_pMapMimeToOpaqueSize = NULL;    m_pASMRuleBook         = NULL;    m_pStreamMimeType      = NULL;}PXWireFormatManager::~PXWireFormatManager(){    Deallocate();}HX_RESULT PXWireFormatManager::CreateObject(PXWireFormatManager** ppObj){    HX_RESULT retVal = HXR_FAIL;    if (ppObj)    {        PXWireFormatManager* pObj = new PXWireFormatManager();        if (pObj)        {            *ppObj = pObj;            retVal = HXR_OK;        }    }    return retVal;}STDMETHODIMP PXWireFormatManager::QueryInterface(REFIID riid, void** ppvObj){    HX_RESULT retVal = HXR_OK;    if (IsEqualIID(riid, IID_IUnknown))    {        AddRef();        *ppvObj = (IUnknown*) this;    }    else    {        *ppvObj = NULL;        retVal  = HXR_NOINTERFACE;    }    return retVal;}STDMETHODIMP_(UINT32) PXWireFormatManager::AddRef(){    return InterlockedIncrement(&m_lRefCount);}STDMETHODIMP_(UINT32) PXWireFormatManager::Release(){        if (InterlockedDecrement(&m_lRefCount) > 0)        return m_lRefCount;    delete this;    return 0;}HX_RESULT PXWireFormatManager::Init(IUnknown* pContext, UINT32 ulStreamVersion){    HX_RESULT retVal = HXR_OK;    // Clear out everything    Deallocate();    Reset();    // Check to make sure the stream version is not too late    if ((HX_GET_MAJOR_VERSION(ulStreamVersion) < HX_GET_MAJOR_VERSION(m_ulHighestSupportedStreamVersion) ||         (HX_GET_MAJOR_VERSION(ulStreamVersion) == HX_GET_MAJOR_VERSION(m_ulHighestSupportedStreamVersion) &&          HX_GET_MINOR_VERSION(ulStreamVersion) <= HX_GET_MINOR_VERSION(m_ulHighestSupportedStreamVersion))) &&        pContext)    {        // Save the calling context        m_pContext = pContext;        m_pContext->AddRef();        // Set the stream version        m_ulStreamVersion = ulStreamVersion;        // Create a list for the codec mimes        HX_DELETE(m_pCodecMimeList);        m_pCodecMimeList = new CHXSimpleList();        if (m_pCodecMimeList)        {            // Create a list for the fx package mimes            HX_DELETE(m_pFXPackageMimeList);            m_pFXPackageMimeList = new CHXSimpleList();            if (m_pFXPackageMimeList)            {                // Create a map                HX_DELETE(m_pMapMimeToOpaqueSize);                m_pMapMimeToOpaqueSize = new CHXMapStringToOb();                if (m_pMapMimeToOpaqueSize)                {                    // Add the number of header bytes for the codecs we know about                    // XXXMEH - this is a hack - there should be NO codec-specific                    // code in here, since it attaches some dependence in between                    // codecs and the renderer.                    m_pMapMimeToOpaqueSize->SetAt("image/vndr.rn-realpix.jpeg", (void*) 12);                    m_pMapMimeToOpaqueSize->SetAt("image/vnd.rn-realpix.gif",   (void*)  8);                    m_pMapMimeToOpaqueSize->SetAt("image/vnd.rn-realpix.png",   (void*)  4);                    // Get an IHXCommonClassFactory interface                    retVal = m_pContext->QueryInterface(IID_IHXCommonClassFactory,                                                        (void**) &m_pCommonClassFactory);                }                else                {                    retVal = HXR_OUTOFMEMORY;                }            }            else            {                retVal = HXR_OUTOFMEMORY;            }        }        else        {            retVal = HXR_OUTOFMEMORY;        }    }    else    {        retVal = HXR_INVALID_PARAMETER;    }    if (FAILED(retVal))    {        Deallocate();        Reset();    }    return retVal;}HX_RESULT PXWireFormatManager::GetFileHeader(REF(IHXValues*) rpFileHeader,                                             const char* pszAcceptMetaInfo){    HX_RESULT retVal = HXR_OK;    // Create an IHXValues object    IHXValues* pValues = NULL;    retVal              = m_pCommonClassFactory->CreateInstance(CLSID_IHXValues,                                                                (void**) &pValues);    if (SUCCEEDED(retVal))    {        // Set properties        pValues->SetPropertyULONG32("StreamCount",    1);        pValues->SetPropertyULONG32("IsRealDataType", 1);        // If there are TAC properties, then set them        if (m_pTitleStr)        {            pValues->SetPropertyBuffer("Title", m_pTitleStr);        }        if (m_pAuthorStr)        {            pValues->SetPropertyBuffer("Author", m_pAuthorStr);        }        if (m_pCopyrightStr)        {            pValues->SetPropertyBuffer("Copyright", m_pCopyrightStr);        }        // Check if we need to set live stream flag        if (m_bIsLive)        {            pValues->SetPropertyULONG32("LiveStream", 1);        }        // Check if we need to set the MinimizeLatency flag        if (m_bMinimizeLatency)        {            pValues->SetPropertyULONG32("MinimizeLatency", 1);        }        // Add the requested meta info (if any)        if (pszAcceptMetaInfo)        {            // Create the IHXValues of available meta info            IHXValues* pMetaInfo = NULL;            m_pCommonClassFactory->CreateInstance(CLSID_IHXValues, (void**) &pMetaInfo);            if (pMetaInfo)            {                // Add the available meta info                pMetaInfo->SetPropertyULONG32("Width",   m_ulDisplayWidth);                pMetaInfo->SetPropertyULONG32("Height",  m_ulDisplayHeight);                pMetaInfo->SetPropertyULONG32("Bitrate", m_ulBitrate);                // Add any requested meta info the file header                AddMetaInfo(pMetaInfo, pszAcceptMetaInfo, pValues);            }            HX_RELEASE(pMetaInfo);        }        // Assign to the out parameter        HX_RELEASE(rpFileHeader);        rpFileHeader = pValues;        rpFileHeader->AddRef();    }    HX_RELEASE(pValues);    return retVal;}HX_RESULT PXWireFormatManager::GetStreamHeader(REF(IHXValues*) rpStreamHeader){    HX_RESULT retVal = HXR_FAIL;    // Check to see if we have valid values for all the    // required members    if (m_pStreamMimeType && m_pASMRuleBook && m_ulBitrate &&        m_ulDuration && m_pCommonClassFactory)    {        IHXValues* pValues = NULL;        retVal              = m_pCommonClassFactory->CreateInstance(CLSID_IHXValues,                                                                    (void**) &pValues);        if (SUCCEEDED(retVal))        {            // Set some properties            pValues->SetPropertyCString("MimeType",          m_pStreamMimeType);            pValues->SetPropertyCString("ASMRuleBook",       m_pASMRuleBook);            pValues->SetPropertyULONG32("StreamNumber",      0);            pValues->SetPropertyULONG32("MaxBitRate",        m_ulBitrate);            pValues->SetPropertyULONG32("AvgBitRate",        m_ulBitrate);            pValues->SetPropertyULONG32("StartTime",         m_ulStart);            pValues->SetPropertyULONG32("Preroll",           m_ulPreroll);            pValues->SetPropertyULONG32("PreData",           m_ulPreData);            pValues->SetPropertyULONG32("Duration",          m_ulDuration);            pValues->SetPropertyULONG32("StreamVersion",     m_ulStreamVersion);            pValues->SetPropertyULONG32("ContentVersion",    m_ulContentVersion);            pValues->SetPropertyULONG32("RendererFlags",     m_ulRendererFlags);            pValues->SetPropertyULONG32("BackgroundOpacity", m_ulBackgroundOpacity);            if (m_bPreDataAtStart)            {                pValues->SetPropertyULONG32("PredataAtStart",   1);            }            if (m_bPrerollAfterSeek)            {                pValues->SetPropertyULONG32("PrerollAfterSeek", 1);            }            // Create an IHXBuffer            IHXBuffer* pOpBuffer = NULL;            retVal                = m_pCommonClassFactory->CreateInstance(CLSID_IHXBuffer,                                                                          (void**) &pOpBuffer);            if (SUCCEEDED(retVal))            {                // Compute the size. When we call PackStreamHeader(,FALSE), it                // only computes the size and doesn't pack the stream header.                BYTE*  pBuf   = NULL;                UINT32 ulSize = PackStreamHeader(pBuf, FALSE);                retVal        = pOpBuffer->SetSize(ulSize);                if (SUCCEEDED(retVal))                {                    if (HX_GET_MAJOR_VERSION(m_ulStreamVersion) <=                        HX_GET_MAJOR_VERSION(m_ulHighestSupportedStreamVersion) &&                        HX_GET_MINOR_VERSION(m_ulStreamVersion) <=                        HX_GET_MINOR_VERSION(m_ulHighestSupportedStreamVersion))                    {                        // Now we call PackStreamHeader(,TRUE), which actually                        // packs the stream header                        pBuf = pOpBuffer->GetBuffer();                        PackStreamHeader(pBuf, TRUE);                    }                    else                    {                        retVal = HXR_FAIL;                    }                    if (SUCCEEDED(retVal))                    {                        // Set the opaque data property                        pValues->SetPropertyBuffer("OpaqueData", pOpBuffer);                        // Assign the out parameter                        HX_RELEASE(rpStreamHeader);                        rpStreamHeader = pValues;                        rpStreamHeader->AddRef();                    }                }            }            HX_RELEASE(pOpBuffer);        }        HX_RELEASE(pValues);    }

⌨️ 快捷键说明

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