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

📄 private_data_task.c

📁 pnx1500 mpeg2 ts stream demo
💻 C
字号:
/*
 * Copyright (c) 2004, 2005 Koninklijke Philips Electronics N V. Includes code
 * copyright (c) 2004 by VCom Electronics Inc; copyright transferred by verbal
 * agreement between Tim Meakin and Jonathan Coxhead, November 2004. All rights
 * reserved.
 *
 * This source code and any compilation or derivative thereof is the proprietary
 * information of Koninklijke Philips Electronics N V and is confidential in
 * nature. Under no circumstances is this software to be exposed to or placed
 * under an Open Source License of any type without the express written
 * permission of Koninklijke Philips Electronics N V.
 *
 * #############################################################################
 *
 * Module: %name: private_data_task.c % %version: 1 %
 *
 * %date_created: Fri Mar 11 11:55:06 2005 % %created_by: jcoxhead %
 *
 * %date_modified: Fri Jun 14 11:31:56 2002 %
 *
 * #############################################################################
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <psos.h>
#include <tmosal.h>
#include <tmMainStreaming.h>
#include <tmDbg.h>
#include "tmalDemuxMpegTS.h"
#include "private_data_task.h"

//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
void
privateDataTask(
    pVoid    pArgs )
{
	tmErrorCode_t  rval                = TM_OK;
	UInt32         in_packets          = 0;
	UInt32         packetSize          = 0;
    UInt32         i                   = 0;
	UInt32         taskID              = 0;
	ptmAvPacket_t  packetPtr           = Null;
	UInt8          *packetStartPtr     = Null;
    ptaskArgs_t    privDataTaskArgsPtr = (ptaskArgs_t)pArgs;
    taskArgs_t     privDataTaskArgs;
#ifndef TURN_OFF_FILE_WRITES
    Int            fd                  = 0;
	Int8           filename[128];
#endif  // TURN_OFF_FILE_WRITES

    DBG_ISR_PRINT( (dbgTsDemux, DBG_INTERNAL_ENTER, "privateDataTask") )

    // Make local copy of parameters passed in on the stack
    privDataTaskArgs.instance = privDataTaskArgsPtr->instance;
    privDataTaskArgs.fullQ    = privDataTaskArgsPtr->fullQ;
    privDataTaskArgs.emptyQ   = privDataTaskArgsPtr->emptyQ;
    strcpy( privDataTaskArgs.fileName, privDataTaskArgsPtr->fileName );

    // Obtain the task identifier
	t_ident( (char *)0, 0, &taskID );
	DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1, "privateDataTask ID=0x%x\n",
                    taskID) )

    EQ_ERRCHK( privDataTaskArgs.instance, 0 )

#ifndef TURN_OFF_FILE_WRITES
	filename[0] = '\0';
	if ( privDataTaskArgs.fileName != Null )
    {
		strcpy( filename, privDataTaskArgs.fileName );
		if ( (fd = open( filename, OPEN_FLAGS, 0644 )) == -1 )
        {
            NOT_EQ_ERRCHK( rval, TM_OK )
            tmosalTaskExit();
		}
	}
#endif  // TURN_OFF_FILE_WRITES

    // Loop forever
    for ( ;; )
    {
        // Wait to receive a full packet from an input connection queue
        ERRCHK( qDataInGetFull( privDataTaskArgs.fullQ, False, &packetPtr ) )

        // Check if we have been ordered to kill ourself
        if ( bKillPrivateDataTask == True )
        {
            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,
                            "privateDataTask: received kill signal, exiting\n") )
            tmosalTaskExit();
        }

        for ( i = 0; i < packetPtr->buffersInUse; i++ )
        {
            packetStartPtr = packetPtr->buffers[i].data;
            packetSize     = packetPtr->buffers[i].dataSize;
            in_packets ++;

#ifndef TURN_OFF_FILE_WRITES
            if ( fd && (packetSize != write( fd, packetStartPtr, packetSize )) )
            {
				NOT_EQ_ERRCHK( errno, 0 )
			}
#endif  // TURN_OFF_FILE_WRITES
		}

        // Return an empty packet to an input connection queue
        ERRCHK( qDataInPutEmpty( privDataTaskArgs.emptyQ, packetPtr ) )
    }  // end loop
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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