[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-datatype-cvs
Subject:    [Datatype-cvs] mpg/payload Umakefil, NONE, 1.1.4.2 mpvespyld.cpp,
From:       kliu () helixcommunity ! org
Date:       2011-04-29 2:20:34
Message-ID: 201104290220.p3T2KL8R011402 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/datatype/mpg/payload
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv16079/payload

Added Files:
      Tag: hxclient_3_6_5_atlas
	Umakefil mpvespyld.cpp 
Log Message:
Modified by: kliu@real.com 
Date: 04/29/2011
Project: RealPlayer for LephoneTD

Synopsis: Porting MPEG1/2 TS support to 365 from HEAD

Overview: Porting files for MPEG1/2 TS support to 365 from HEAD based on Jamie's \
                recommendations.  Files were gathered based on the following commited \
                CR's:
CR: mpeg-1/2 video TS support in producer
CR: add log 4cc for MPEG video
CR: MPEG-1/2 video in TS streams and files
CR: MPEG-1/2 video depacketizer

Files Added:
datatype/mpg/common/pub/mpgvidcommon.h
datatype/mpg/common/mpgvidcommon.cpp
datatype/mpg/payload/mpvespyld.cpp
datatype/mpg/payload/Umakefil
datatype/mpg/payload/pub/mpvespyld.h
datatype/mpeg2ts/demuxer/payload/mpvpayload.cpp
datatype/mpeg2ts/demuxer/pub/mpvpayload.h
datatype/mpeg2ts/stream/guids.cpp
datatype/mpeg2ts/stream/tsstreamff.cpp
datatype/mpeg2ts/stream/tsstreamff.ver
datatype/mpeg2ts/stream/Umakefil
datatype/mpeg2ts/stream/pub
datatype/mpeg2ts/stream/pub/tsstreamff.h

Files Modified:
datatype/mp4/video/renderer/dllumakefil
datatype/mp4/video/renderer/libumakefil
datatype/mp4/video/renderer/mp4vdec.cpp
datatype/mp4/video/renderer/mp4vdfmt.cpp
datatype/mp4/video/renderer/mp4video.cpp

datatype/mpeg2ts/demuxer/payload/aacpayload.cpp
datatype/mpeg2ts/demuxer/payload/h264payload.cpp
datatype/mpeg2ts/demuxer/pub/aacpayload.h
datatype/mpeg2ts/demuxer/pub/h264payload.h
datatype/mpeg2ts/demuxer/pub/tsdemuxer.h
datatype/mpeg2ts/demuxer/tsdemuxer.cpp
datatype/mpeg2ts/demuxer/Umakefil
datatype/mpeg2ts/fileformat/tsfformat.cpp
datatype/mpeg2ts/fileformat/Umakefil

common/include/ihxtlogsystem.h
client/build/BIF/hxclient_3_6_5_atlas.bif

Image Size and Heap Use impact (Client -Only): 
None

Platforms and Profiles Affected: 
Platform: android-2.3-arm-smdk_c110
Profile: helix-client-android-full

Distribution Libraries Affected: 
None 

Distribution library impact and planned action: 
None 

Platforms and Profiles Build Verified: 
Platform: android-2.3-arm-smdk_c110
Profile: helix-client-android-full

Platforms and Profiles Functionality verified: 
Platform: android-2.3-arm-smdk_c110
Profile: helix-client-android-full

Branch: 365atlas
 
Copyright assignment: I am a RealNetworks employee or contractor


--- NEW FILE: mpvespyld.cpp ---
/* ***** BEGIN LICENSE BLOCK *****
 * Source last modified: $Id: mpvespyld.cpp,v 1.1.4.2 2011/04/29 02:20:32 kliu Exp $
 * 
 * Portions Copyright (c) 1995-2005 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 (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 ***** */
/****************************************************************************
 /*
 *  Includes
 */
#include "hxtypes.h"
#include "hxwintyp.h"
#include "hxcom.h"
#include "hxcomm.h"

#include "hxassert.h"
#include "hxslist.h"
#include "hxstrutl.h"
#include "hxcomm.h"
#include "ihxpckts.h"
#include "hxformt.h"
#include "hxrendr.h"
#include "hxformt.h"
#include "hxengin.h"

#include "bitstuff.h"
#include "hxcodec.h"
#include "hxalloc.h"

#include "mpvespyld.h"

 /*  Defines
 */
#define FLUSH_ALL_PACKETS   0xFFFFFFFF

#define MP1VES_PAYLOAD_MIME_TYPE	    "video/x-hx-mp1v-es"
#define MP2VES_PAYLOAD_MIME_TYPE	    "video/x-hx-mp2v-es"


const char* const MPEGESPayloadFormat::m_ppszCodecId[] = {"MPGV", NULL};


MPEGESPayloadFormat::MPEGESPayloadFormat(CHXBufferMemoryAllocator* pAllocator)
    : m_lRefCount(0)
    , m_pClassFactory(NULL)
    , m_pAllocator(NULL)
    , m_pStreamHeader(NULL)
    , m_usStreamNumber(MAX_UINT16)
    , m_ulInputQueueTotalSize(0)
    , m_pBitstreamHeader(NULL)
    , m_ulBitstreamHeaderSize(0)
    , m_ulPacketizationMode(0)
    , m_ulCodecDataSeqNumber(0)
    , m_ulCodecIDIndex(0)
    , m_bFlushed(FALSE)
    , m_bUsesRTPPackets(FALSE)
    , m_bRTPPacketTested(FALSE)
    , m_ulSamplesPerSecond(1000)
    , m_ulRTPSamplesPerSecond(0)
{
    ;
}

MPEGESPayloadFormat::~MPEGESPayloadFormat()
{
    Close();
}

HX_RESULT MPEGESPayloadFormat::Build(REF(IMP4VPayloadFormat*) pFmt)
{
    pFmt = new MPEGESPayloadFormat();

    HX_RESULT res = HXR_OUTOFMEMORY;
    if (pFmt)
    {
        pFmt->AddRef();
        res = HXR_OK;
    }

    return res;
}

// *** IUnknown methods ***

/******************************************************************************
  Method:
  IUnknown::QueryInterface
  Purpose: Everyone usually implements this the same... feel free to use
    this implementation.
******************************************************************************/
STDMETHODIMP
MPEGESPayloadFormat::QueryInterface(REFIID riid, void** ppvObj)
{
    QInterfaceList qiList[] =
    {
        { GET_IIDHANDLE(IID_IUnknown), this },
        { GET_IIDHANDLE(IID_IHXPayloadFormatObject), (IHXPayloadFormatObject*) this \
},  };
    return ::QIFind(qiList, QILISTSIZE(qiList), riid, ppvObj);
}

/******************************************************************************
  Method:
  IUnknown::AddRef
  Purpose: Everyone usually implements this the same... feel free to use
    this implementation.
******************************************************************************/
STDMETHODIMP_(ULONG32)
MPEGESPayloadFormat::AddRef()
{
    return InterlockedIncrement(&m_lRefCount);
}

/******************************************************************************
    Method:
    IUnknown::Release
    Purpose:
    Everyone usually implements this the same... feel free to use 
    this implementation.
******************************************************************************/
STDMETHODIMP_(ULONG32)
MPEGESPayloadFormat::Release()
{
    if (InterlockedDecrement(&m_lRefCount) > 0)
    {
        return m_lRefCount;
    }

    delete this;
    return 0;
}


STDMETHODIMP
MPEGESPayloadFormat::Init(IUnknown* pContext, HXBOOL bPacketize)
{
    HX_RESULT retVal = HXR_OK;

    // we are a depacktizer only
    if (bPacketize) 
    {
        return HXR_NOT_SUPPORTED;
    }
    HX_RELEASE(m_pClassFactory);
    if (SUCCEEDED(retVal))
    {
        retVal = pContext->QueryInterface(IID_IHXCommonClassFactory, (void**) \
&m_pClassFactory);  }

    return retVal;
}

STDMETHODIMP
MPEGESPayloadFormat::Close()
{
    Reset();
    HX_VECTOR_DELETE(m_pBitstreamHeader);
    if (m_pAllocator)
    {
        m_pAllocator->Release();
        m_pAllocator = NULL;
    }
    HX_RELEASE(m_pClassFactory);
    HX_RELEASE(m_pStreamHeader);

    return HXR_OK;
}


STDMETHODIMP
MPEGESPayloadFormat::Reset()
{
    FlushQueues();
    m_bFlushed = FALSE;
    m_TSConverter.Reset();
    return HXR_OK;
}

STDMETHODIMP
MPEGESPayloadFormat::SetStreamHeader(IHXValues* pHeader)
{
    HX_RELEASE(m_pStreamHeader);
    m_pStreamHeader = pHeader;
    HX_ADDREF(m_pStreamHeader);
    return SetAssemblerHeader(pHeader);
}

void MPEGESPayloadFormat::SetAllocator(CHXBufferMemoryAllocator* pAllocator)
{
    HX_RELEASE(m_pAllocator);
    m_pAllocator = pAllocator;
    HX_ADDREF(m_pAllocator);    
}

HX_RESULT MPEGESPayloadFormat::SetAssemblerHeader(IHXValues* pHeader)
{
    IHXBuffer* pMimeType = NULL;
    const char* pMimeTypeData = NULL;
    HX_RESULT retVal = HXR_INVALID_PARAMETER;

    if (pHeader)
    {
        retVal = HXR_OK;
    }

    if (SUCCEEDED(retVal))
    {
        retVal = pHeader->GetPropertyCString("MimeType", pMimeType);
    }

    if (SUCCEEDED(retVal))
    {
        pMimeTypeData = (char*) pMimeType->GetBuffer();

        retVal = HXR_FAIL;
        if (pMimeTypeData)
        {
            retVal = HXR_OK;
        }
    }

    // Determine this is the mime type we support
    if (SUCCEEDED(retVal))
    {
        retVal = HXR_FAIL;

            if (strcasecmp(pMimeTypeData, MP1VES_PAYLOAD_MIME_TYPE) == 0 ||
                strcasecmp(pMimeTypeData, MP2VES_PAYLOAD_MIME_TYPE) == 0)
        {
            retVal = HXR_OK;
        }
    }

    if (SUCCEEDED(retVal))
    {
         m_pStreamHeader->GetPropertyULONG32("SamplesPerSecond",
                                            m_ulRTPSamplesPerSecond);
    }

    HX_RELEASE(pMimeType);

    return retVal;
}

STDMETHODIMP
MPEGESPayloadFormat::GetStreamHeader(REF(IHXValues*) pHeader)
{
    HX_RESULT retVal = HXR_FAIL;

    if (m_pStreamHeader)
    {
        retVal = HXR_OK;
        pHeader = m_pStreamHeader;
        pHeader->AddRef();
    }

    return retVal;
}

STDMETHODIMP
MPEGESPayloadFormat::SetPacket(IHXPacket* pPacket)
{
    HX_RESULT retVal = HXR_OK;

    HX_ASSERT(pPacket);

    if (!m_bRTPPacketTested)
    {
        IHXRTPPacket* pRTPPacket = NULL;
        m_bUsesRTPPackets = (pPacket->QueryInterface(IID_IHXRTPPacket,
                                        (void**) &pRTPPacket) == HXR_OK);

        m_bRTPPacketTested = TRUE;
        HX_RELEASE(pRTPPacket);

        if (m_bUsesRTPPackets)
        {
            if (m_ulRTPSamplesPerSecond == 0)
            {
                m_ulRTPSamplesPerSecond = m_ulSamplesPerSecond;
            }

            HX_ASSERT(m_ulSamplesPerSecond != 0);
        }
        else
        {
            m_ulRTPSamplesPerSecond = 1000; // RDT time stamp
        }

        m_TSConverter.SetBase(m_ulRTPSamplesPerSecond,
                                m_ulSamplesPerSecond);
    }

    if (m_usStreamNumber == MAX_UINT16)
    {
        m_usStreamNumber = pPacket->GetStreamNumber();
    }

    //extract NAL info from the packet
    retVal = ProcessPacket(pPacket);
    return retVal;
}

STDMETHODIMP
MPEGESPayloadFormat::GetPacket(REF(IHXPacket*) pOutPacket)
{
    HX_RESULT retVal = HXR_NOTIMPL;
    return retVal;
}

HX_RESULT MPEGESPayloadFormat::CreateHXCodecPacket(UINT32* &pHXCodecDataOut)
{
    HX_RESULT retVal = HXR_OK;

    void* pHXCodecData = NULL;
    if (!m_OutputQueue.IsEmpty())
    {
        pHXCodecData = m_OutputQueue.RemoveHead();
    }

    if (!pHXCodecData && m_bFlushed)
    {
        retVal = HXR_STREAM_DONE;
    }

    pHXCodecDataOut = (UINT32*)pHXCodecData;

    return retVal;
}

const char* MPEGESPayloadFormat::GetCodecId()
{
    return m_ppszCodecId[m_ulCodecIDIndex];
}

HX_RESULT MPEGESPayloadFormat::SetNextCodecId()
{
    HX_RESULT retVal = HXR_FAIL;

    // Is our current codec ID non-NULL?
    if (m_ppszCodecId[m_ulCodecIDIndex])
    {
        // Advance the codec ID index
        m_ulCodecIDIndex++;
        // Now is our codec index non-NULL?
        if (m_ppszCodecId[m_ulCodecIDIndex])
        {
            // If we have a non-NULL codec ID, then clear the return value
            retVal = HXR_OK;
        }
    }

    return retVal;
}

void MPEGESPayloadFormat::ResetCodecId()
{
    m_ulCodecIDIndex = 0;
}

HX_RESULT MPEGESPayloadFormat::ProcessPacket(IHXPacket* pPacket)
{
    HX_RESULT retVal = HXR_OK;
    IHXBuffer* pBuffer = NULL;
    UINT8* pData = NULL;
    UINT8 uPacketHeader = 0; 

    INT32 ulBuffSize = 0;
    UINT32 offset = 0;
    UINT32 ulTimeOffset = 0;

    UINT16 usASMRule = pPacket->GetASMRuleNumber();
    UINT8  ucASMFlags = pPacket->GetASMFlags();

    HXBOOL bLost = pPacket->IsLost();

    if(!bLost)
    {
        pBuffer = pPacket->GetBuffer();

        if(pBuffer)
        {
            pData = pBuffer->GetBuffer();
            ulBuffSize = pBuffer->GetSize();
        }

        if (pData && ulBuffSize > 0)
        {
            // Add this packet to our list of input packets
            if (SUCCEEDED(retVal))
            {
                HX_ASSERT(m_InputQueue.IsEmpty());
                pPacket->AddRef();
                m_InputQueue.AddTail(pPacket);
                m_ulInputQueueTotalSize += ulBuffSize;
            }

            // convert AU into CodecData and put into the output queue
            if (SUCCEEDED(retVal))
            {
                retVal = ReapMediaPacket();
            }
        }

        HX_RELEASE(pBuffer);
    }
    else
    {
       // lost packet
       ++m_ulCodecDataSeqNumber;
    }

    return retVal;
}

HX_RESULT MPEGESPayloadFormat::ReapMediaPacket(void)
{
    HX_RESULT retVal = HXR_OK;

    IHXPacket* pPacket = NULL;
    IHXBuffer* pBuffer = NULL;
    UINT32 ulSize = 0;

    HXCODEC_DATA* pHXCodecData = NULL;	
    HXCODEC_SEGMENTINFO* pHXCodecSegmentInfo = NULL;
    UINT32* pCodecDataBuf = NULL;
    
    pPacket = (IHXPacket*)(m_InputQueue.GetHead());
    if (!pPacket)
    {
        return HXR_NO_DATA;
    }

    // Allocate codec data header
    pCodecDataBuf = new UINT32[(sizeof(HXCODEC_DATA) + 3) / 4];
    if(!pCodecDataBuf)
    {
        return HXR_OUTOFMEMORY;
    }

    pBuffer = pPacket->GetBuffer();
    ulSize = pBuffer->GetSize();

    // Init. codec data header
    pHXCodecData = (HXCODEC_DATA*) pCodecDataBuf;
    pHXCodecData->timestamp = GetPacketTime(pPacket);
    pHXCodecData->sequenceNum = (UINT16)m_ulCodecDataSeqNumber; 
    pHXCodecData->flags = pPacket->GetASMFlags();
    pHXCodecData->lastPacket = FALSE;
    pHXCodecData->dataLength = ulSize;

    pHXCodecData->numSegments = 1; 
    pHXCodecData->Segments[0].bIsValid = TRUE;
    pHXCodecData->Segments[0].ulSegmentOffset = 0;

    if (m_pAllocator)
    {
        pHXCodecData->data = m_pAllocator->AddBuffer(pBuffer);
    }
    else
    {
        pHXCodecData->data = (UINT8*) new UINT32[(ulSize + 3)/ 4];
        if (pHXCodecData->data)
        {
            memcpy(pHXCodecData->data, pBuffer->GetBuffer(), ulSize);
        }
        else
        {
            HX_DELETE(pHXCodecData);
            retVal = HXR_OUTOFMEMORY;
        }
    }

    HX_RELEASE(pBuffer);

    if (SUCCEEDED(retVal))
    {
        m_InputQueue.RemoveHead();
        HX_RELEASE(pPacket);
    
        m_OutputQueue.AddTail(pHXCodecData);
        m_ulCodecDataSeqNumber++;
    }

    return retVal;
}


STDMETHODIMP
MPEGESPayloadFormat::Flush()
{
    m_bFlushed = TRUE;
    return HXR_OK;
}

void MPEGESPayloadFormat::FlushQueues(void)
{
    FlushInputQueue(FLUSH_ALL_PACKETS);
    FlushOutputQueue(FLUSH_ALL_PACKETS);
}

void MPEGESPayloadFormat::FlushInputQueue(UINT32 ulCount)
{
    IHXPacket* pDeadPacket;

    while ((ulCount > 0) && (!m_InputQueue.IsEmpty()))
    {
        pDeadPacket = (IHXPacket*) m_InputQueue.RemoveHead();
        HX_RELEASE(pDeadPacket);
        if (ulCount != FLUSH_ALL_PACKETS)
        {
            ulCount--;
        }
    }
    m_ulInputQueueTotalSize = 0;
}

void MPEGESPayloadFormat::FlushOutputQueue(UINT32 ulCount)
{
    while ((ulCount > 0) && (!m_OutputQueue.IsEmpty()))
    {
        HXCODEC_DATA* pDeadPacket = (HXCODEC_DATA*) m_OutputQueue.RemoveHead();
        if (m_pAllocator)
        {
           m_pAllocator->ReleasePacketPtr(pDeadPacket->data);
        }
        else
        {
           HX_VECTOR_DELETE(pDeadPacket->data);
        }
        HX_DELETE(pDeadPacket);
        if (ulCount != FLUSH_ALL_PACKETS)
        {
            ulCount--;
        }
    }
}

UINT32 MPEGESPayloadFormat::GetPacketTime(IHXPacket* pPacket)
{
    UINT32 ulTime;

    HX_ASSERT(pPacket);

    if (m_bUsesRTPPackets)
    {
        ulTime = ((IHXRTPPacket*) pPacket)->GetRTPTime();
    }
    else
    {
        ulTime = pPacket->GetTime();
    }

    ulTime = m_TSConverter.Convert(ulTime);

    return ulTime;
}

--- NEW FILE: Umakefil ---
# 
# ***** BEGIN LICENSE BLOCK ***** 
# Version: RCSL 1.0/RPSL 1.0 
#  
# Portions Copyright (c) 1995-2002 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 
# Version 1.0 (the "RPSL") available at 
# http://www.helixcommunity.org/content/rpsl unless you have licensed 
# the file under the RealNetworks Community Source License Version 1.0 
# (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.  
#  
# 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 ***** 
# 

UmakefileVersion(2,1)

project.AddModuleIncludes(
    "common/include",
    "common/runtime/pub",
    "common/dbgtool/pub",
    "common/container/pub",
    "common/system/pub",
    "common/util/pub",
    "datatype/mp4/payload/pub",
    "datatype/rm/include",      # for hxcodec.h
    "datatype/rm/common/pub"    # for hxalloc.h
    )

project.AddSources("mpvespyld.cpp")

LibraryTarget("mpegpyld")


_______________________________________________
Datatype-cvs mailing list
Datatype-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/datatype-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic