qtatmmgs.h

来自「symbian 下的helix player源代码」· C头文件 代码 · 共 688 行 · 第 1/2 页

H
688
字号
/* ***** 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 ***** */ 

#ifndef _QTATMMGS_H_
#define _QTATMMGS_H_

/****************************************************************************
 *  Defines
 */
#define _STCO_ZERO_BASED_IQ
#define _STSD_ZERO_BASED_IQ
#define _STSS_ZERO_BASED_IQ
#define _TINF_NO_MEDIA_SCALE_IQ

// Enable identification of SYNC packets with ASM_SWITCH_ON/OFF flags
#define _STSS_TRACK_SYNC    

#define QT_BAD_IDX	0xFFFFFFFF
#define QT_BAD_PAYLOAD	0xFFFFFFFF

#ifdef QTCONFIG_SPEED_OVER_SIZE
#define QTATMMGS_INLINE inline
#else	// QTCONFIG_SPEED_OVER_SIZE
#define QTATMMGS_INLINE /**/
#endif	// QTCONFIG_SPEED_OVER_SIZE

/****************************************************************************
 *  Includes
 */
#include "qtatoms.h"
#include "hxcomm.h"

class CQTTrackManager;
class CQT_MovieInfo_Manager;


/****************************************************************************
 *  Track Edit Manager
 *  Note: All locally stored times are in media units
 */
class CQT_TrackEdit_Manager
{
public:
    /*
     *	Constructor/Destructor
     */
    CQT_TrackEdit_Manager(void);
    ~CQT_TrackEdit_Manager();

    /*
     *	Main Interface
     */
    HX_RESULT Init( CQTAtom* pAtom, 
		    ULONG32 ulMovieTimeScale,
		    ULONG32 ulMediaTimeScale);

    BOOL EstablishByTime(ULONG32 ulTime); // Given in miliseconds

    BOOL AdvanceByMediaTime(ULONG32 ulMediaTime, BOOL &bDone)  // media units
    {
	m_ulCurrentInEditTime += ulMediaTime;
	bDone = FALSE; // Assume Not Done

	if (m_ulCurrentInEditTime < m_ulCurrentEditDuration)
	{
	    return FALSE;  // No Edit Advancement
	}
	else
	{
	    // We have to move onto the next edit
	    if (!SequenceToEdit())
	    {
		bDone = TRUE;
		m_ulCurrentInEditTime -= ulMediaTime;
	    }

	    return TRUE;  // Edit Advancement (possibly failed)
	}
    }

    ULONG32 GetMediaTime(void)  // in media units
    {
	return m_ulCurrentMediaStartTime + m_ulCurrentInEditTime;
    }

    double GetRealTime(void)  // in miliseconds
    {
	return (((double) (m_ulCurrentEditTime + m_ulCurrentInEditTime)) *
	        1000.0 /
		((double) m_ulMediaTimeScale));
    }

private:
    BOOL SequenceToEdit(void);

    ULONG32 MovieToMediaUnits(ULONG32 ulMovieTime)
    {
	return (ULONG32) ((((double) ulMovieTime) / m_ulMovieTimeScale) * 
			  m_ulMediaTimeScale + 0.5);
    }

    CQT_elst_Atom* m_pEditListAtom;

    ULONG32 m_ulMovieTimeScale;
    ULONG32 m_ulMediaTimeScale;

    ULONG32 m_ulNumEdits;
    ULONG32 m_ulCurrentEditIdx;
    ULONG32 m_ulCurrentEditTime;
    ULONG32 m_ulCurrentInEditTime;
    ULONG32 m_ulCurrentEditDuration;
    ULONG32 m_ulCurrentMediaStartTime;  
};

/****************************************************************************
 *  Sample To Chunk Manager
 */
class CQT_SampleToChunk_Manager
{
public:
    /*
     *	Constructor/Destructor
     */
    CQT_SampleToChunk_Manager(void);
    ~CQT_SampleToChunk_Manager();

    /*
     *	Main Interface
     */
    HX_RESULT Init(CQTAtom* pAtom);

    BOOL EstablishBySample(ULONG32 ulSampleNum);

    BOOL AdvanceBySample(void)
    {
	m_ulSampleNumber++;
	m_ulSampleInChunkNum++;

	return SequenceToChunk();
    }

    BOOL AdvanceToNextChunk(void)
    {
	m_ulSampleNumber += (m_ulSamplesPerChunk - m_ulSampleInChunkNum);
	m_ulSampleInChunkNum = m_ulSamplesPerChunk;

	return AdvanceBySample();
    }

    ULONG32 GetChunkNum(void)		{ return m_ulCurrentChunk; }
    ULONG32 GetChunkSampleNum(void)	{ return m_ulSampleInChunkNum; }
    ULONG32 GetChunkSampleCount(void)	{ return m_ulSamplesPerChunk; }
    ULONG32 GetSampleDescIdx(void)	{ return m_ulSampleDescIdx; }
    ULONG32 GetSampleNum(void)		{ return m_ulSampleNumber; }
    
private:
    BOOL SequenceToChunk(void);
    inline BOOL SequenceReverseToChunk(void);

    CQT_stsc_Atom* m_pSampleToChunkAtom;

    ULONG32 m_ulNumEntries;
    ULONG32 m_ulSampleInChunkNum;
    ULONG32 m_ulCurrentChunk;
    ULONG32 m_ulNextEntryChunk;
    ULONG32 m_ulCurrentEntryIdx;
    ULONG32 m_ulSamplesPerChunk;
    ULONG32 m_ulSampleNumber;
    ULONG32 m_ulSampleDescIdx;
#ifdef _STCO_ZERO_BASED_IQ
    ULONG32 m_ulChunkNumOffset;
#endif	// _STCO_ZERO_BASED_IQ
};

/****************************************************************************
 *  Time To Sample Manager
 *  Note: All time locals are in media time units
 */
class CQT_TimeToSample_Manager
{
public:
    /*
     *	Constructor/Destructor
     */
    CQT_TimeToSample_Manager(void);
    ~CQT_TimeToSample_Manager();

    /*
     *	Main Interface
     */
    HX_RESULT Init(CQTAtom* pAtom);

    BOOL EstablishByMediaTime(ULONG32 ulMediaTime);
    BOOL EstablishAtKeyByMediaTime(ULONG32 ulMediaTime);

    QTATMMGS_INLINE BOOL AdvanceSyncSampleNumber(void);
    QTATMMGS_INLINE BOOL AdvanceCompBySample(void);
    QTATMMGS_INLINE BOOL AdvanceBySample(void);

    BOOL EstablishCompBySample(ULONG32 ulSampleNum);

    ULONG32 GetSampleNumber(void)	{ return m_ulSampleNumber; }
    ULONG32 GetSampleDuration(void)	{ return m_ulSampleDuration; }
    ULONG32 GetCompositionOffset(void)	{ return m_ulCompOffset; }
    ULONG32 GetLastMediaSyncTime(void)	{ return m_ulLastSyncTime; }
    ULONG32 GetSyncSampleNumber(void)	{ return m_ulSyncSampleNumber; }
    BOOL    IsOnSyncSample(void)	{ return (m_ulSyncSampleNumber == 
						  m_ulSampleNumber); }

private:
    CQT_stts_Atom* m_pTimeToSampleAtom;
    CQT_ctts_Atom* m_pCompOffsetAtom;
    CQT_stss_Atom* m_pSyncSampleAtom;

    ULONG32 m_ulNumEntries;
    ULONG32 m_ulCurrentEntryIdx;
    ULONG32 m_ulSampleNumber;
    ULONG32 m_ulSamplesLeftInEntry;
    ULONG32 m_ulSampleDuration;
    ULONG32 m_ulLastSyncTime;

    ULONG32 m_ulNumCompEntries;
    ULONG32 m_ulCurrentCompEntryIdx;
    ULONG32 m_ulCompSampleNumber;
    ULONG32 m_ulSamplesLeftInCompEntry;
    ULONG32 m_ulCompOffset;

    ULONG32 m_ulNumSyncEntries;
    ULONG32 m_ulCurrentSyncEntryIdx;
    ULONG32 m_ulSyncSampleNumber;

#ifdef _STSS_ZERO_BASED_IQ
    ULONG32 m_ulKeyFrameNumOffset;
#endif	// _STSS_ZERO_BASED_IQ
};

/****************************************************************************
 *  Sample Size Manager
 */
class CQT_SampleSize_Manager
{
public:
    /*
     *	Constructor/Destructor
     */
    CQT_SampleSize_Manager(void);
    ~CQT_SampleSize_Manager();

    /*
     *	Main Interface
     */
    HX_RESULT Init(CQTAtom* pAtom);

    BOOL EstablishBySample(ULONG32 ulSampleNum, 
			   ULONG32 ulChunkSampleNum,
			   ULONG32 ulSamplesPerChunk = 0);

    ULONG32 GetSampleSize(void)		{ return m_ulSampleSize; }
    ULONG32 GetChunkSampleOffset(void)	{ return m_ulChunkSampleOffset; }
    ULONG32 GetChunkSize(void)		{ return m_ulChunkSize; }

private:
    CQT_stsz_Atom* m_pSampleSizeAtom;

    ULONG32 m_ulGenericSize;
    ULONG32 m_ulSampleSize;
    ULONG32 m_ulChunkSampleOffset;
    ULONG32 m_ulChunkSize;
    ULONG32 m_ulNumEntries;
    ULONG32 m_ulChunkStartSampleNum;
    ULONG32 m_ulSampleNum;
};

/****************************************************************************
 *  Chunk To Offset Manager
 */
class CQT_ChunkToOffset_Manager
{
public:
    /*
     *	Constructor/Destructor
     */
    CQT_ChunkToOffset_Manager(void);
    ~CQT_ChunkToOffset_Manager();

    /*
     *	Main Interface
     */
    HX_RESULT Init(CQTAtom* pAtom);

    BOOL EstablishByChunk(ULONG32 ulChunkNum)
    {
	if ((ulChunkNum > 0) &&
	    (ulChunkNum <= m_ulNumEntries))
	{
	    m_ulChunkOffset = m_pChunkToOffsetAtom->Get_ChunkOffset(ulChunkNum - 1);
	    return TRUE;
	}

	return FALSE;
    }

    ULONG32 GetChunkOffset(void)    { return m_ulChunkOffset; }

private:
    CQT_stco_Atom* m_pChunkToOffsetAtom;

    ULONG32 m_ulChunkOffset;
    ULONG32 m_ulNumEntries;
};

/****************************************************************************

⌨️ 快捷键说明

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