📄 ts_pin.cpp
字号:
/*+++ *******************************************************************\
*
* Copyright and Disclaimer:
*
* ---------------------------------------------------------------
* This software is provided "AS IS" without warranty of any kind,
* either expressed or implied, including but not limited to the
* implied warranties of noninfringement, merchantability and/or
* fitness for a particular purpose.
* ---------------------------------------------------------------
*
* Copyright (c) 2008 Conexant Systems, Inc.
* All rights reserved.
*
\******************************************************************* ---*/
#include "ts_pin.h"
#include "Device.h"
#include "debug.h"
#include "miscfuncs.h"
const ULONG TS_FRAMES_TO_CYCLE = 20;
/////////////////////////////////////////////////////////////////////////////////////////
TS_Pin::TS_Pin(PKSPIN p_ks_pin,
NTSTATUS &status):
BasePin(p_ks_pin)
{
PVOID p_context = KsPinGetDevice(p_ks_pin)->Context;
Device* p_device = static_cast<Device*>(p_context);
status = init(
TS_FRAMES_TO_CYCLE,
320*188, //buffer size (16*188)
0); //frame duration
}
/////////////////////////////////////////////////////////////////////////////////////////
NTSTATUS TS_Pin::dispatchCreate(
PKSPIN p_ks_pin,
PIRP p_irp)
{
NTSTATUS status = STATUS_SUCCESS;
p_ks_pin->Context = new TS_Pin(p_ks_pin, status);
if(!p_ks_pin->Context)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
if(!NT_SUCCESS(status))
{
delete (TS_Pin*)p_ks_pin->Context;
}
return status;
}
/////////////////////////////////////////////////////////////////////////////////////////
NTSTATUS TS_Pin::static_IntersectHandler(
PKSFILTER p_filter,
PIRP p_irp,
PKSP_PIN p_pin_instance,
PKSDATARANGE p_caller_data_range, //data range to verify.
PKSDATARANGE p_descriptor_data, //Our data range
ULONG buffer_size,
PVOID p_data,
PULONG p_data_size)
{
if( !p_filter || !p_irp || !p_pin_instance || !p_caller_data_range || !p_descriptor_data || !p_data_size )
{
return STATUS_INSUFFICIENT_RESOURCES;
}
//If buffer_size is 0, the user just wants the size.
if(buffer_size == 0)
{
*p_data_size = sizeof(KSDATAFORMAT);
return STATUS_BUFFER_OVERFLOW;
}
if(buffer_size < sizeof(KSDATAFORMAT))
{
return STATUS_BUFFER_TOO_SMALL;
}
//Copy the data format into the buffer.
RtlCopyMemory(
p_data,
p_descriptor_data,
sizeof(KSDATAFORMAT));
return STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////////
VOID TS_Pin::fillFrameInfo(PKSSTREAM_HEADER p_strm_hdr, FIELD_TYPE field_type)
{
//We don't do frame info on the audio pin
return;
}
/////////////////////////////////////////////////////////////////////////////////////////
PIN_TYPES TS_Pin::getPinType()
{
return PIN_TYPE_TS_MPEG;
}
PIN_TYPES TS2_Pin::getPinType()
{
return PIN_TYPE_TS2_MPEG;
}
TS2_Pin::TS2_Pin(PKSPIN p_ks_pin,
NTSTATUS &status):
TS_Pin(p_ks_pin, status)
{
}
NTSTATUS TS2_Pin::dispatchCreate(
PKSPIN p_ks_pin,
PIRP p_irp)
{
NTSTATUS status = STATUS_SUCCESS;
p_ks_pin->Context = new TS2_Pin(p_ks_pin, status);
if(!p_ks_pin->Context)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
if(!NT_SUCCESS(status))
{
delete (TS2_Pin*)p_ks_pin->Context;
}
return status;
}
/////////////////////////////////////////////////////////////////////////////////////////
const KSPIN_DISPATCH g_ts_pin_dispatch =
{
TS_Pin::dispatchCreate, // Pin Create
BasePin::dispatchClose, // Pin Close
BasePin::dispatchProcess, // Pin Process
NULL, // Pin Reset
NULL, // Pin Set Data Format
BasePin::dispatchSetState, // Pin Set Device State
NULL, // Pin Connect
NULL, // Pin Disconnect
NULL, // Clock Dispatch
NULL // Allocator Dispatch
};
const KSPIN_DISPATCH g_ts2_pin_dispatch =
{
TS2_Pin::dispatchCreate, // Pin Create
BasePin::dispatchClose, // Pin Close
BasePin::dispatchProcess, // Pin Process
NULL, // Pin Reset
NULL, // Pin Set Data Format
BasePin::dispatchSetState, // Pin Set Device State
NULL, // Pin Connect
NULL, // Pin Disconnect
NULL, // Clock Dispatch
NULL // Allocator Dispatch
};
/////////////////////////////////////////////////////////////////////////////////////////
NTSTATUS
TsCaptureFilter::
dispatchCreate(
KSFILTER *p_ks_filter,
IRP *p_irp
)
{
Device* p_device = getDevice(p_irp);
DbgLogInfo(("TsCaptureFilter::dispatchCreate: setting Medium Id on TS capture Input Pin\n"));
if(p_device)
{
setMediumId(p_ks_filter,0, p_device->getMediumId() );
}
return STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////////
const
KSFILTER_DISPATCH
TsCaptureFilterDispatch =
{
TsCaptureFilter::dispatchCreate, // Filter Create
NULL, // Filter Close
NULL, // Filter Process
NULL // Filter Reset
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -