📄 dvdcmd.c
字号:
switch (IntersectInfo->StreamNumber) {
case strmVideo:
pFormat = &hwfmtiMpeg2Vid;
formatSize = sizeof hwfmtiMpeg2Vid;
break;
case strmAudio:
if (IsEqualGUID2(&(DataRange->SubFormat), &(Mpeg2AudioFormat.DataFormat.SubFormat))) {
// DebugPrint( (DebugLevelError, "DVDTS: AC3 Audio format query\r\n") );
pFormat = (PKSDATAFORMAT) &Mpeg2AudioFormat;
formatSize = sizeof (KSDATAFORMAT_WAVEFORMATEX);
}
else if (IsEqualGUID2(&(DataRange->SubFormat), &(LPCMAudioFormat.DataFormat.SubFormat))) {
// DebugPrint( (DebugLevelError, "DVDTS: LPCM Audio format query\r\n") );
pFormat = (PKSDATAFORMAT) &LPCMAudioFormat;
formatSize = sizeof (KSDATAFORMAT_WAVEFORMATEX);
}
else {
// DebugPrint( (DebugLevelError, "DVDTS: unknown Audio format query\r\n") );
pFormat = NULL;
formatSize = 0;
}
break;
case strmSubpicture:
pFormat = &hwfmtiMpeg2Subpic;
formatSize = sizeof hwfmtiMpeg2Subpic;
break;
case strmYUVVideo:
DebugPrint( (DebugLevelTrace, "DVDTS: VPE\r\n") );
pFormat = &hwfmtiVPEOut;
formatSize = sizeof hwfmtiVPEOut;
break;
case strmCCOut:
DebugPrint(( DebugLevelTrace, "DVDTS: CC\r\n" ));
pFormat = &hwfmtiCCOut;
formatSize = sizeof hwfmtiCCOut;
break;
default:
DebugPrint( (DebugLevelTrace, "DVDTS: STATUS_NOT_IMPLEMENTED\r\n") );
pSrb->Status = STATUS_NOT_IMPLEMENTED;
return;
} // end streamnumber switch
if (pFormat) {
//
// do a minimal compare of the dataranges to at least verify
// that the guids are the same.
//
DataRange = IntersectInfo->DataRange;
if (!(IsEqualGUID2(&DataRange->MajorFormat,
&pFormat->MajorFormat) &&
IsEqualGUID2(&DataRange->Specifier,
&pFormat->Specifier))) {
DebugPrint( (DebugLevelTrace, "DVDTS: STATUS_NO_MATCH\r\n") );
Status = STATUS_NO_MATCH;
} else { // if guids are equal
//
// check to see if the size of the passed in buffer is a ULONG.
// if so, this indicates that we are to return only the size
// needed, and not return the actual data.
//
// if (IntersectInfo->StreamNumber == strmAudio)
// DebugPrint( (DebugLevelError, "DVDTS: Audio GUIDs are equal\r\n") );
if (IntersectInfo->SizeOfDataFormatBuffer != sizeof(ULONG)) {
//
// we are to copy the data, not just return the size
//
if (IntersectInfo->SizeOfDataFormatBuffer < formatSize) {
DebugPrint( (DebugLevelTrace, "DVDTS: STATUS_BUFFER_TOO_SMALL\r\n") );
Status = STATUS_BUFFER_TOO_SMALL;
} else { // if too small
RtlCopyMemory(IntersectInfo->DataFormatBuffer,
pFormat,
formatSize);
pSrb->ActualBytesTransferred = formatSize;
// if (IntersectInfo->StreamNumber == strmAudio)
// DebugPrint( (DebugLevelError, "DVDTS: Audio STATUS_SUCCESS\r\n") );
DebugPrint( (DebugLevelTrace, "DVDTS: STATUS_SUCCESS(data copy)\r\n") );
Status = STATUS_SUCCESS;
} // if too small
} else { // if sizeof ULONG specified
//
// caller wants just the size of the buffer. Get that.
//
*(PULONG) IntersectInfo->DataFormatBuffer = formatSize;
pSrb->ActualBytesTransferred = sizeof(ULONG);
DebugPrint( (DebugLevelTrace, "DVDTS: STATUS_SUCCESS(return size)\r\n") );
} // if sizeof ULONG
} // if guids are equal
} else { // if pFormat
DebugPrint( (DebugLevelTrace, "DVDTS: STATUS_NOT_SUPPORTED\r\n") );
Status = STATUS_NOT_SUPPORTED;
} // if pFormat
pSrb->Status = Status;
return;
}
/*
** AdapterOpenStream()
*/
VOID AdapterOpenStream( PHW_STREAM_REQUEST_BLOCK pSrb )
{
PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
pSrb->Status = STATUS_SUCCESS;
pHwDevExt->lCPPStrm = -1; // reset the copy protection stream number.
ASSERT( pHwDevExt->CppFlagCount == 0 );
ASSERT( pHwDevExt->pSrbCpp == NULL );
ASSERT( pHwDevExt->bCppReset == FALSE );
pHwDevExt->CppFlagCount = 0;
pHwDevExt->pSrbCpp = NULL;
pHwDevExt->bCppReset = FALSE;
switch( pSrb->StreamObject->StreamNumber ){
case strmVideo:
DebugPrint( (DebugLevelTrace, "DVDTS: Video\r\n") );
pSrb->StreamObject->ReceiveDataPacket =
VideoReceiveDataPacket;
pSrb->StreamObject->ReceiveControlPacket =
VideoReceiveCtrlPacket;
pHwDevExt->pstroVid = pSrb->StreamObject;
ProcessVideoFormat( pSrb->CommandData.OpenFormat, pHwDevExt );
DeviceQueue_init(pHwDevExt);
SetVideoRateDefault( pHwDevExt );
// If you would like to take out of previous picture,
// insert codes here to reset and initialize MPEG Decoder Chip.
pHwDevExt->cOpenInputStream++;
decVsyncOn(pHwDevExt);
decClosedCaptionOn( pHwDevExt );
break;
case strmAudio:
DebugPrint( (DebugLevelTrace, "DVDTS: Audio\r\n") );
pSrb->StreamObject->ReceiveDataPacket =
AudioReceiveDataPacket;
pSrb->StreamObject->ReceiveControlPacket =
AudioReceiveCtrlPacket;
pSrb->StreamObject->HwClockObject.HwClockFunction = StreamClockRtn;
pSrb->StreamObject->HwClockObject.ClockSupportFlags =
CLOCK_SUPPORT_CAN_SET_ONBOARD_CLOCK | CLOCK_SUPPORT_CAN_READ_ONBOARD_CLOCK |
CLOCK_SUPPORT_CAN_RETURN_STREAM_TIME;
pHwDevExt->pstroAud = pSrb->StreamObject;
ProcessAudioFormat( pSrb->CommandData.OpenFormat, pHwDevExt );
pSrb->StreamObject->HwEventRoutine = (PHW_EVENT_ROUTINE) AudioEvent;
fStarted = fProgrammed = FALSE;
SetAudioRateDefault( pHwDevExt );
pHwDevExt->cOpenInputStream++;
break;
case strmSubpicture:
DebugPrint( (DebugLevelTrace, "DVDTS: Subpic\r\n") );
pSrb->StreamObject->ReceiveDataPacket =
SubpicReceiveDataPacket;
pSrb->StreamObject->ReceiveControlPacket =
SubpicReceiveCtrlPacket;
pHwDevExt->pstroSP = pSrb->StreamObject;
SetSubpicRateDefault( pHwDevExt );
pHwDevExt->cOpenInputStream++;
break;
case strmYUVVideo:
DebugPrint( (DebugLevelTrace, "DVDTS: VPE\r\n") );
pSrb->StreamObject->ReceiveDataPacket =
VpeReceiveDataPacket;
pSrb->StreamObject->ReceiveControlPacket =
VpeReceiveCtrlPacket;
pHwDevExt->pstroYUV = pSrb->StreamObject;
pSrb->StreamObject->HwEventRoutine = (PHW_EVENT_ROUTINE) CycEvent;
break;
case strmCCOut:
DebugPrint(( DebugLevelTrace, "DVDTS: CC\r\n" ));
pSrb->StreamObject->ReceiveDataPacket =
CCReceiveDataPacket;
pSrb->StreamObject->ReceiveControlPacket =
CCReceiveCtrlPacket;
pHwDevExt->pstroCC = pSrb->StreamObject;
CCQueue_init(pHwDevExt);
break;
default:
DebugPrint( (DebugLevelTrace, "DVDTS: default %d(0x%x)\r\n", pSrb->StreamObject->StreamNumber, pSrb->StreamObject->StreamNumber ) );
TRAP;
break;
}
pSrb->StreamObject->Dma = TRUE;
pSrb->StreamObject->Pio = TRUE; // Need Pio = TRUE for access on CPU
}
/*
** AdapterCloseStream()
*/
VOID AdapterCloseStream( PHW_STREAM_REQUEST_BLOCK pSrb )
{
PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
pSrb->Status = STATUS_SUCCESS;
switch ( pSrb->StreamObject->StreamNumber ) {
case strmVideo:
DebugPrint(( DebugLevelTrace, "DVDTS: Video\r\n" ));
pHwDevExt->pstroVid = NULL;
pHwDevExt->cOpenInputStream--;
// Temporary ??
pHwDevExt->XferStartCount = 0;
pHwDevExt->DecodeStart = FALSE;
pHwDevExt->SendFirst = FALSE;
break;
case strmAudio:
DebugPrint(( DebugLevelTrace, "DVDTS: Audio\r\n" ));
pHwDevExt->pstroAud = NULL;
pHwDevExt->cOpenInputStream--;
break;
case strmSubpicture:
DebugPrint(( DebugLevelTrace, "DVDTS: Subpic\r\n" ));
pHwDevExt->pstroSP = NULL;
pHwDevExt->cOpenInputStream--;
break;
case strmYUVVideo:
DebugPrint(( DebugLevelTrace, "DVDTS: VPE\r\n" ));
pHwDevExt->pstroYUV = NULL;
decSetVideoPort( pHwDevExt, 0 ); // Disable
break;
case strmCCOut:
DebugPrint(( DebugLevelTrace, "DVDTS: CC\r\n" ));
pHwDevExt->pstroCC = NULL;
// PHW_STREAM_REQUEST_BLOCK pSrbTmp;
// for( ; ; ) {
// pSrbTmp = pHwDevExt->CCQue.get();
// if( pSrbTmp == NULL )
// break;
// pSrbTmp->Status = STATUS_SUCCESS;
//
// DebugPrint(( DebugLevelTrace, "DVDTS: CC pSrb = 0x%x\r\n", pSrbTmp ));
//
// StreamClassStreamNotification( StreamRequestComplete,
// pSrbTmp->StreamObject,
// pSrbTmp );
// }
break;
default:
DebugPrint( (DebugLevelTrace, "DVDTS: default %d(0x%x)\r\n", pSrb->StreamObject->StreamNumber, pSrb->StreamObject->StreamNumber ) );
TRAP;
break;
}
}
/*
** ClockEvents ()
**
** handle any time event mark events
**
** Arguments:
**
**
**
** Returns:
**
** Side Effects:
*/
void ClockEvents( PHW_DEVICE_EXTENSION pHwDevExt )
{
//
// This is called from the VSync ISR once every 12 times that the ISR is entered.
//
PKSEVENT_ENTRY pEvent, pLast;
PMYTIME pTim;
LONGLONG MinIntTime;
LONGLONG strmTime;
if( !pHwDevExt || !pHwDevExt->pstroAud || !pHwDevExt->pstroSP )
return;
strmTime = LastStamp + ( GetSystemTime() - LastSys );
//
// loop through all time_mark events
//
pEvent = NULL;
pLast = NULL;
while(( pEvent = StreamClassGetNextEvent(
pHwDevExt,
pHwDevExt->pstroAud,
(GUID *)&KSEVENTSETID_Clock,
KSEVENT_CLOCK_POSITION_MARK,
pLast )) != NULL )
{
DebugPrint((
DebugLevelTrace,
"DVDTS:ClockEvent(1) 0x%s, 0x%s\r\n",
DebugLLConvtoStr( ((PKSEVENT_TIME_MARK)(pEvent +1))->MarkTime, 16 ),
DebugLLConvtoStr( strmTime, 16 )
));
//c DebugPrint(( DebugLevelTrace, "DVDTS: strmTime 0x%x\r\n", strmTime ));
//c DebugPrint(( DebugLevelTrace, "DVDTS: LastStamp 0x%x\r\n", LastStamp ));
//c DebugPrint(( DebugLevelTrace, "DVDTS: GetSystemTime() 0x%x\r\n", GetSystemTime() ));
//c DebugPrint(( DebugLevelTrace, "DVDTS: LastSys 0x%x\r\n", LastSys ));
// TRAP;
if (((PKSEVENT_TIME_MARK)(pEvent +1))->MarkTime <= strmTime ) {
DebugPrint(( DebugLevelTrace, "DVDTS: Notify\r\n" ));
// TRAP;
//
// signal the event here
//
StreamClassStreamNotification(
SignalStreamEvent,
pHwDevExt->pstroAud,
pEvent
);
}
pLast = pEvent;
}
//
// loop through all time_interval events
//
pEvent = NULL;
pLast = NULL;
while(( pEvent = StreamClassGetNextEvent(
pHwDevExt,
pHwDevExt->pstroAud,
(GUID *)&KSEVENTSETID_Clock,
KSEVENT_CLOCK_INTERVAL_MARK,
pLast )) != NULL )
{
//
// check if this event has been used for this interval yet
//
pTim = ((PMYTIME)(pEvent + 1));
DebugPrint((
DebugLevelTrace,
"DVDTS:ClockEvent(2) strmTime 0x%s\r\n",
DebugLLConvtoStr( strmTime, 16 )
));
DebugPrint((
DebugLevelTrace,
"DVDTS: Interval 0x%s\r\n",
DebugLLConvtoStr( pTim->tim.Interval, 16 )
));
DebugPrint((
DebugLevelTrace,
"DVDTS: TimeBase 0x%s\r\n",
DebugLLConvtoStr( pTim->tim.TimeBase, 16 )
));
if (pTim && pTim->tim.Interval)
{
if (pTim->tim.TimeBase <= strmTime)
{
MinIntTime = (strmTime - pTim->tim.TimeBase) / pTim->tim.Interval;
MinIntTime *= pTim->tim.Interval;
MinIntTime += pTim->tim.TimeBase;
DebugPrint((
DebugLevelTrace,
"DVDTS: MinIntTime 0x%s\r\n",
DebugLLConvtoStr( MinIntTime, 16 )
));
DebugPrint((
DebugLevelTrace,
"DVDTS: LastTime 0x%s\r\n",
DebugLLConvtoStr( pTim->LastTime, 16 )
));
if (MinIntTime > pTim->LastTime )
{
DebugPrint(( DebugLevelTrace, "DVDTS: Notify\r\n" ));
TRAP;
//
// signal the event here
//
StreamClassStreamNotification(
SignalStreamEvent,
pHwDevExt->pstroAud,
pEvent
);
pTim->LastTime = strmTime;
}
}
}
else
{
DebugPrint(( DebugLevelTrace, "DVDTS:ClockEvent(?)\r\n" ));
TRAP;
}
pLast = pEvent;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -