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

📄 cdemux.h

📁 这是DVD中伺服部分的核心代码
💻 H
字号:
/*****************************************************************************
******************************************************************************
**                                                                          **
**  Copyright (c) 2002 Videon Central, Inc.                                 **
**  All rights reserved.                                                    **
**                                                                          **
**  The computer program contained herein contains proprietary information  **
**  which is the property of Videon Central, Inc.  The program may be used  **
**  and/or copied only with the written permission of Videon Central, Inc.  **
**  or in accordance with the terms and conditions stipulated in the        **
**  agreement/contract under which the programs have been supplied.         **
**                                                                          **
******************************************************************************
*****************************************************************************/
/**
 * @file cDemux.h
 *
 * Software Demux source file.
 *
 * $Id: cDemux.h,v 1.10 2006/06/15 15:13:16 micah Exp $
 */
#ifndef CDEMUX_H
#define CDEMUX_H

/******************************************************************************
*******************************************************************************
**                                                                           **
**  Demux Defines                                                            **
**                                                                           **
*******************************************************************************
******************************************************************************/

/**
 * @def     ENABLE_DEMUX_REMAP_FEATURE
 * @brief   Enables / disables the remapping feature of the demux.
 */
#define ENABLE_DEMUX_REMAP_FEATURE	1

/**
 * @def Demux Status Defines
 * @brief Pass is 0, Fail is 1.
 */
#define DEMUX_PASS  0
#define DEMUX_FAIL  1

/**
 * @def Demux State Defines
 * @brief Stopped is 0, Started is 1.
 */
#define DEMUX_STOPPED  0
#define DEMUX_STOPPING 1
#define DEMUX_STARTED  2
#define DEMUX_DELETE   3

/**
 * @def Demux Stream Type Defines
 * @brief MPEG1 is 0, MPEG2 is 1.
 */
enum DEMUX_STREAM_TYPE
{
  DEMUX_NONE = 0,
#ifdef __DEMUX_TS_SUPPORT__
  DEMUX_TRANSPORT,
#endif
#ifdef __DEMUX_MP3_SUPPORT__
  DEMUX_MP3,
#endif
  DEMUX_MPEG1,
  DEMUX_MPEG2
};

/**
 * @def Demux Stack Size Define
 * @brief Defines the size of the demux stack.
 */
#define DEMUX_STACK_SIZE  8192

/**
 * @def Maximum Output Stream Count Define
 * @brief Defines the maximum number of output streams to be handled by
 *        the demux.
 *
 * This will need to be used by the Demux and the POS.
 */
#define OUTPUT_STREAM_MAX_COUNT  5

/**
 * @def DEMUXINPUTMESSAGE
 * @brief Typedef for the input message of the Demux
 *
 * Messages that will be used by the input stream to the Demux.
 */
typedef cPEStreamMessage DEMUXINPUTMESSAGE;

/**
 * @def DEMUXOUTPUTMESSAGE
 * @brief Typedef for the output message of the Demux
 *
 * Messages that will be used by the output stream of the Demux.
 */
typedef cPEModuleStreamMessage DEMUXOUTPUTMESSAGE;

/**
 * @def DEMUXIOSTREAM
 * @brief Typedef for an I/O stream of the Demux
 *
 * An I/O stream to be used by the Demux.
 */
typedef cStream DEMUXIOSTREAM;

/**
 * @def DEMUXINPUTPIN
 * @brief Typedef for the input pin of the Demux
 *
 * Just another name for DEMUXIOSTREAM.
 */
typedef DEMUXIOSTREAM DEMUXINPUTPIN;

/*
 * Just another name for cPayload
 */
typedef cPayload DEMUXPAYLOAD;

enum DEMUX_TIMESTAMP_TYPE
{
    DEMUX_PTS = 0,
    DEMUX_DTS,
    DEMUX_ANY
};

/**
 * Demux Types
 */
typedef enum tagOUTPUT_STREAM_TYPE
{
    UNDEFINED = 0,
    PES,
    PSI,
    AUDIO,
    VIDEO,
    NVPCK,
    HDNVPCK,
    DATA,
    BYPASS
} OUTPUT_STREAM_TYPE;

/**
 * @def DEMUXOUTPUTPIN
 * @brief Typedef for an output pin of the Demux
 *
 * An output pin of the Demux containing configuration information which stores
 * the desired PES_ID and SUB_ID combination.
 */
typedef struct tagDemuxOutputPin
{
    BYTE                 bPesID;
    BYTE                 bSubID;
    BOOLEAN              fFirstPayload;
    DEMUX_TIMESTAMP_TYPE tTimeType;
    OUTPUT_STREAM_TYPE   tStreamType;
    DEMUXIOSTREAM        *pDestStream;

#ifdef __DEMUX_TS_SUPPORT__
    BOOLEAN              fSendPayload;
    SHORT                wPID;
#endif

} DEMUXOUTPUTPIN;

/**
 * @def DEMUXCONFIGINFO
 * @brief Defines the configuration information structure of the Demux.
 *
 * Records the configuration information of the Demux class.
 */
typedef struct tagDemuxConfigInfo
{
    ULONG           ulDemuxState;
    int             iOutputPinCount;
    DEMUXINPUTPIN   *tInputPin;
    BOOLEAN         fUpdateOutputPins;
    OS_SEM_ID       semPinUpdate;
    OS_SEM_ID       semPinSync;
    DEMUXOUTPUTPIN  tOutputPin[OUTPUT_STREAM_MAX_COUNT];
#if ENABLE_DEMUX_REMAP_FEATURE
    OS_SEM_ID       semRemapUpdate;
    BOOLEAN         fUpdateRemap;
    BYTE            bRemapStreamID;
    BYTE            bRemapSubStreamID;
    BYTE            bRemapStreamIDValue;
    BYTE            bRemapSubStreamIDValue;
#endif
} DEMUXCONFIGINFO;

/******************************************************************************
*******************************************************************************
**                                                                           **
**  Demux Interface                                                          **
**                                                                           **
*******************************************************************************
******************************************************************************/

/**
 * @class cDemux
 *
 * @brief Parses streaming data and sends the corresponding payload to the
 *        appropriate location.
 */
class cDemux
{
public:

    /**
     * Demux constructor.
     *
     * @param
     *    None.
     */
    cDemux();

    /**
     * Demux destructor.
     *
     * @param
     *    None.
     */
    ~cDemux();

    /**
     * Demux new operator.
     *
     * @param
     *    size_t size - size of the Demux object
     *
     * @retval
     *    Pointer to the new Demux object if successful
     *    NULL if not successful
     */
    PVOID operator new( size_t size )
    {
        return (PVOID)OS_MemAlloc(size);
    }

    /**
     * Demux delete operator.
     *
     * @param
     *    PVOID pvDemux - pointer to the Demux object to delete
     *
     * @retval
     *    None.
     */
    void operator delete( PVOID pvDemux )
    {
        OS_MemFree(pvDemux);
    }

    /**
     * Create function. Spawns the Demux task.
     *
     * @param
     *    char *strDemuxName - Names the Demux task
     *
     * @param
     *    BOOLEAN fStreamType - Selects MPEG1 or MPEG2 as the stream to demux
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN Create( char *strDemuxName, DEMUX_STREAM_TYPE tStreamType );

    /**
     * Start function. Starts the Demux task.
     *
     * @param
     *    None.
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN Start( void );

    /**
     * Stop function. Stops the Demux task by placing it into a
     * suspended state.
     *
     * @param
     *    None.
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN Stop( void );

    /**
     * Delete function. Kills the Demux task.
     *
     * @param
     *    None.
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN Delete( void );

    /**
     * Attach Input Stream function. Provides the Demux with a cStream object
     * from which it will read all of its input data.
     *
     * @param
     *    DEMUXIOSTREAM *pInputStream - pointer to the cStream object to be
     *                                  assigned to the Demux.
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN AttachInputStream( DEMUXIOSTREAM *pInputStream );

    /**
     * Detach Input Stream function. Detaches the previously attached cStream
     * object from the Demux.
     *
     * @param
     *    None.
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN DetachInputStream( void );

    /**
     * Attach Output Stream function. Configures the Demux to send the payload
     * data of an input stream with the given PES_ID and SUB_ID combination to
     * the given cStream object.
     *
     * @param
     *    BYTE bPesID - Stream ID to associate with the given destination
     *                  stream object.
     *
     * @param
     *    BYTE bSubID - Sub-Stream ID to associate with the given destination
     *                  stream object.
     *
     * @param
     *    DEMUXIOSTREAM *pOutputStream - Stream object to send payload data to
     *                                   when a stream is found with the given
     *                                   PES_ID and SUB_ID combination.
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN AttachOutputStream(BYTE                 bPesID,
                               BYTE                 bSubID,
                               DEMUX_TIMESTAMP_TYPE tTimeType,
                               OUTPUT_STREAM_TYPE   tStreamType,
                               DEMUXIOSTREAM        *pOutputStream
                               );

#ifdef __DEMUX_TS_SUPPORT__
    /**
     * Attach Output PID Stream function. Configures the Demux to send the payload
     * data of an input stream with the given PID
     *
     * @param
     *    WORD wPID -  PID to associate with the given destination
     *                  stream object.
     *
     * @param
     *    DEMUXIOSTREAM *pOutputStream - Stream object to send payload data to
     *                                   when a stream is found with the given
     *                                   PES_ID and SUB_ID combination.
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN AttachOutputPIDStream(SHORT                wPID,
                                  DEMUX_TIMESTAMP_TYPE tTimeType,
                                  OUTPUT_STREAM_TYPE   tStreamType,
                                  DEMUXIOSTREAM        *pOutputStream
                                  );
#endif

    /**
     * Detach Output Stream function. Detaches the given output stream from the
     * Demux.
     *
     * @param
     *    DEMUXIOSTREAM *pOutputStream - Stream object to detach from the Demux
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN DetachOutputStream( DEMUXIOSTREAM *pOutputStream );

    /**
     * Get Status function. Returns the number of Demux errors.
     *
     * @param
     *    None.
     *
     * @retval
     *    Number of demux errors.
     */
    ULONG DemuxGetStatus(void);
    DEMUX_STREAM_TYPE DemuxGetType(void);

    ULONG DemuxGetNumberOutputPins(void)
    {
        return (tDemuxConfigInfo.iOutputPinCount);
    }

#if ENABLE_DEMUX_REMAP_FEATURE
    /**
     * Remap Stream function. Remaps the specified stream/substream pair as per the
     * following guidelines:
     *
     *      1.) If the stream ID is not tagged for remap, the corresponding
     *          sub-stream ID will not be remapped.
     *      2.) If bInStreamSubID = bOutStreamSubID = NO_SUB_ID, then only the
     *          stream ID is remapped.
     *      3.) If bInStreamSubID = NO_SUB_ID, then all sub-stream IDs are
     *          remapped regardless of what they are.
     *
     * @param
     *    BYTE bInStreamID - Input stream ID to be remapped.
     *
     * @param
     *    BYTE bInStreamSubID - Input sub-stream ID to be remapped.
     *
     * @param
     *    BYTE bOutStreamID - Value to be used when remapping the specified
     *                        input stream ID.
     *
     * @param
     *    BYTE bOutStreamSubID - Value to be used when remapping the specified
     *                           input sub-stream ID.
     *
     * @retval
     *    DEMUX_PASS - if successful
     *    DEMUX_FAIL - if not successful
     */
    BOOLEAN RemapStream(BYTE bInStreamID,
                        BYTE bInStreamSubID,
                        BYTE bOutStreamID,
                        BYTE bOutStreamSubID
                        );
#endif

private:
    DEMUX_STREAM_TYPE tCurrentType;
    int iDemuxThreadID;
    DEMUXCONFIGINFO tDemuxConfigInfo;
};

#endif




⌨️ 快捷键说明

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