3gppttstructs.h

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

H
639
字号
/* ***** BEGIN LICENSE BLOCK ***** 
 * Version: RCSL 1.0/RPSL 1.0 
 *  
 * Portions Copyright (c) 1995-2003 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 _3GPPTTSTRUCTS_H_
#define _3GPPTTSTRUCTS_H_

/****************************************************************************
 *  Includes
 */
#include "hxtypes.h"
#include "hxresult.h"
#include "hxassert.h"

#include "3gppttutils.h"


// /These are individual flag bits in C3GPPTextSampleEntry::m_ulDisplayFlags :
#define HX_3GPPTT_DISPLAYFLAGS_SCROLL_IN          0x00000020
#define HX_3GPPTT_DISPLAYFLAGS_SCROLL_OUT         0x00000040
// /8th bit set means horizontal motion (else vertical), 9th bit set means
// from top or left, (else from bottom or right):
#define HX_3GPPTT_DISPLAYFLAGS_SCROLL_DIR_MASK    0x00000180
#define HX_3GPPTT_DISPLAYFLAGS_SCROLL_DIR_UP      0x00000000
#define HX_3GPPTT_DISPLAYFLAGS_SCROLL_DIR_RTOL    0x00000080
#define HX_3GPPTT_DISPLAYFLAGS_SCROLL_DIR_DOWN    0x00000100
#define HX_3GPPTT_DISPLAYFLAGS_SCROLL_DIR_LTOR    0x00000180
// /Non-scroll display flags:
#define HX_3GPPTT_DISPLAYFLAGS_CONTINUOUS_KARAOKE 0x00000800
#define HX_3GPPTT_DISPLAYFLAGS_WRITE_VERTICALLY   0x00020000

#define HX_3GPPTT_JUSTIFICATION_LEFT              0
#define HX_3GPPTT_JUSTIFICATION_TOP               0
#define HX_3GPPTT_JUSTIFICATION_CENTER            1 /* Horiz or vert */
#define HX_3GPPTT_JUSTIFICATION_RIGHT             (-1)
#define HX_3GPPTT_JUSTIFICATION_BOTTOM            (-1)

// /Single-bit FaceStyle flags:
#define HX_3GPPTT_FACE_STYLE_PLAIN                0
#define HX_3GPPTT_FACE_STYLE_BOLD                 1
#define HX_3GPPTT_FACE_STYLE_ITALIC               2
#define HX_3GPPTT_FACE_STYLE_UNDERLINE            4

#define HX_3GPPTT_HYPERLINK_RGB_COLOR       0x00FF0000 /* Red */
#define HX_3GPPTT_FULLY_TRANSPARENT         0xFF000000

// /box-type 4-cc codes
#define HX_3GPPTT_4CC_LEN   4
#define HX_3GPPTT_STYL_4CC  "styl"
#define HX_3GPPTT_HLIT_4CC  "hlit"
#define HX_3GPPTT_HCLR_4CC  "hclr"
#define HX_3GPPTT_KROK_4CC  "krok"
#define HX_3GPPTT_DLAY_4CC  "dlay"
#define HX_3GPPTT_HREF_4CC  "href"
#define HX_3GPPTT_TBOX_4CC  "tbox"
#define HX_3GPPTT_BLNK_4CC  "blnk"

#define HX_3GPPTT_INVALID_INDEX   ((UINT16)-1)
#define HX_3GPPTT_MAX_CHAR_OFFSET (((UINT16)-1)-1)
#define HX_3GPPTT_INVALID_TIME    ((UINT32)-1)
#define HX_3GPPTT_INVALID_INT16   (-1)

#define HX_3GPPTT_BLINK_HALFINTERVAL_TIME   1000 /* in milliseconds */



//TBOX
class C3GPPTextboxBox
{
public:
    C3GPPTextboxBox() : m_top(0), m_left(0), m_bottom(0), m_right(0) {}

    HX_RESULT Build(const UINT8*& pData);

    INT16 Top() const { return m_top; }
    INT16 Left() const { return m_left; }
    INT16 Bottom() const { return m_bottom; }
    INT16 Right() const { return m_right; }

private:
    INT16 m_top;
    INT16 m_left;
    INT16 m_bottom;
    INT16 m_right;

};


//STYL
class C3GPPStyleRecord
{
public:
    C3GPPStyleRecord() 
        : m_uiStartCharOffset(0)
        , m_uiEndCharOffset(0)
        , m_uiFontID(0)
        , m_uFaceStyleFlags(0)
        , m_uFontSize(0)
        , m_textColor(0) {}

    HX_RESULT Build(const UINT8*& pData);

    UINT16 GetStartOffset() const { return m_uiStartCharOffset;}
    UINT16 GetEndOffset() const { return m_uiEndCharOffset;}
    UINT16 GetFontID() const { return m_uiFontID;}
    UINT8 GetFaceStyleFlags() const { return m_uFaceStyleFlags; }
    UINT8 GetFontSize() const { return m_uFontSize; }
    UINT32 GetTextColor() const { return m_textColor; }

private:
    UINT16 m_uiStartCharOffset;
    UINT16 m_uiEndCharOffset;
    UINT16 m_uiFontID;
    UINT8  m_uFaceStyleFlags; // /FACE_STYLE + {_PLAIN, _BOLD, _ITALIC, _UNDERLINE}.
    UINT8  m_uFontSize;
    UINT32  m_textColor; // argb

};


//FTAB entry
class C3GPPFontRecord
{
public:
    C3GPPFontRecord() : m_uiFontID(0) {}

    HX_RESULT Build(const UINT8*& pData);

    UINT16 GetFontID() const { return m_uiFontID; }
    const char* GetFontName() const { return m_strFont; }

private:
    UINT16 m_uiFontID;
    SimpleString m_strFont;
 
};

//FTAB
class C3GPPFontTableBox
{
public:
    C3GPPFontTableBox() : m_ulFontTableSizeInBytes(0) {}
    ~C3GPPFontTableBox();

    HX_RESULT Build(const UINT8*& pData);

    UINT32 GetFontTableSize() const { return m_ulFontTableSizeInBytes;}
    UINT16 GetEntryCount() const { return (UINT16)m_entries.GetCount(); }
    const C3GPPFontRecord* GetFontRecord(UINT16 idx) const
    { 
        HX_ASSERT(idx < m_entries.GetCount());
        return (C3GPPFontRecord*)(m_entries.GetItem(idx));
    }

private:
    void CleanUp();
private:

    UINT32          m_ulFontTableSizeInBytes;
    SimpleArray     m_entries;
};



enum TextSampleScrollDirection
{
      scrollDirNone
    , scrollDirUp
    , scrollDirRightToLeft
    , scrollDirDown
    , scrollDirLeftToRight
};

// /From MP4 stsd atom class:
class C3GPPArrayEntry
{
public:

    HX_RESULT Build(const UINT8*& pData)
    {
        // we don't use any of this data (just skip)
        pData += 16;
        return HXR_OK;
    }

    //UINT8 pSize[4];
    //UINT8 pDataFormat[4];
    //UINT8 pReserved[6];
    //UINT8 pDataRefIdx[2];
};

//TX3G
class C3GPPTextSampleEntry 
: public C3GPPArrayEntry 
{
public:
    C3GPPTextSampleEntry();

    HX_RESULT Build(const UINT8*& pData);

public:
    BOOL hasScrollIn() const  { return (m_ulDisplayFlags & HX_3GPPTT_DISPLAYFLAGS_SCROLL_IN); }
    BOOL hasScrollOut() const { return (m_ulDisplayFlags & HX_3GPPTT_DISPLAYFLAGS_SCROLL_OUT); }
    BOOL hasContinuousKaraoke() const { return (m_ulDisplayFlags & HX_3GPPTT_DISPLAYFLAGS_CONTINUOUS_KARAOKE); }
    BOOL hasWriteVertically()  const { return (m_ulDisplayFlags & HX_3GPPTT_DISPLAYFLAGS_WRITE_VERTICALLY); }

    TextSampleScrollDirection getScrollDirection() const;

    INT8 GetHorJust() const { return m_horizontalJustification; }
    INT8 GetVerJust() const { return m_verticalJustification; }

    UINT32 GetBGColor() const { return m_bgColor; }
    const C3GPPTextboxBox& GetDefaultTextBox() const { return m_defaultTextBox; }
    const C3GPPStyleRecord& GetDefaultStyle() const { return m_defaultStyle; }
    const C3GPPFontTableBox& GetFontTable() const { return m_fontTable; }

private:

    UINT32            m_ulDisplayFlags;
    INT8              m_horizontalJustification; // /JUSTIFICATION_LEFT, ...etc.
    INT8              m_verticalJustification;   // /JUSTIFICATION_TOP, ...etc.
    UINT32            m_bgColor;
    C3GPPTextboxBox   m_defaultTextBox;
    C3GPPStyleRecord  m_defaultStyle;
    C3GPPFontTableBox m_fontTable;


};


class C3GPPTextSampleModifierBox // /extends Box(type)
{
  public:
    enum ModifierType
    {
        STYL,
        HLIT,
        HCLR,
        KROK,
        DLAY,
        HREF,
        TBOX,
        BLNK,
        UNKNOWN
    };

    C3GPPTextSampleModifierBox() : m_ulSize(0), m_type(UNKNOWN), m_pData(0) {}

    HX_RESULT Build(const UINT8*& pData);

    const UINT8* GetData() const { return m_pData; }
    ModifierType GetType() const { return m_type; }
    UINT32 GetTotalSize() const { return m_ulSize; }
    UINT32 GetDataSize() const { HX_ASSERT(m_ulSize >= 8); return m_ulSize - 8; }
  private:
    C3GPPTextSampleModifierBox::ModifierType ReadType(const UINT8*& pData);

    UINT32 m_ulSize; 
    ModifierType m_type;
    const UINT8* m_pData;

};

inline
HX_RESULT C3GPPTextSampleModifierBox::Build(const UINT8*& pData)
{
    m_ulSize = ReadUL32(pData);
    m_type = ReadType(pData);
    m_pData = pData;
    return HXR_OK;
}



class C3GPPTextSample
{
public:      
    
    C3GPPTextSample(IHXBuffer* pIHXBuff);
    ~C3GPPTextSample() { HX_RELEASE(m_pIHXBuff); }

    const char* GetText() const { return m_pText; }
    UINT16 GetTextLenInBytes() const { return m_uiTextLengthInBytes; }
    const UINT8* GetModifierData() const { return m_pTextModifierData; }
    UINT16 GetModifierDataSize() const { return m_uiTextModifiersTotalSize;}

private:
    HX_RESULT Init(IHXBuffer* pIHXBuff);

⌨️ 快捷键说明

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