資源描述:
《Player 無縫連接》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、unitRenderFilter;interfaceuses?Directshow9,DSUtil,BaseClass,ActiveX,Windows,Log,Sample,PushManager,SysUtils,WMF9;type?TPlayerVideoRenderFilter=class(TBCBaseRenderer?)//視頻?private?public??functionDoRenderSample(MediaSample:IMediaSample):HResult;override;??functionCheckMediaType(MediaType:PAMM
2、ediaType):HResult;override;???procedureOnReceiveFirstSample(MediaSample:IMediaSample);override;?end;?TPlayerAudioRenderFilter=class(TBCBaseRenderer)?private?public??functionDoRenderSample(MediaSample:IMediaSample):HResult;override;??functionCheckMediaType(MediaType:PAMMediaType):HResult;over
3、ride;???procedureOnReceiveFirstSample(MediaSample:IMediaSample);override;?end;implementation{TPlayerRenderFilter}functionTPlayerVideoRenderFilter.CheckMediaType(?MediaType:PAMMediaType):HResult;beginresult:=E_FAIL;?ifIsEqualGUID(MediaType.majortype,MediaType_Video)=falsethen??exit;?ifIsEqual
4、GUID(MediaType.subtype,CommonType.VideoCommonType.SubType)=falsethen??exit;?ifIsEqualGUID(MediaType.formattype,CommonType.VideoCommonType.FormatType)=FALSEthen??exit;result:=S_OK;end;functionTPlayerVideoRenderFilter.DoRenderSample(?MediaSample:IMediaSample):HResult;var?Len:integer;?Starttime
5、,EndTime:int64;?Des,Src:pbyte;?flags:DWord;begin?Src:=nil;?des:=nil;?flags:=0;?Len:=MediaSample.GetActualDataLength();?//視頻SAMPLE大小是可變的,音頻則不是,GetSize方法是獲得所有大小,而此方法是獲得有效數(shù)據(jù)的大小?PushSampleManager.AllocSample(Len,true);?PushSampleManager.VideoSample.SetLength(Len);?MediaSample.GetPointer(src);?Pu
6、shSampleManager.VideoSample.GetBuffer(des);?Move(Src^,Des^,Len);?//MediaSample.GetMediaTime(Starttime,Endtime);?MediaSample.GetTime(Starttime,Endtime);?//這里才得到了真正的時間戳?ifMediaSample.IsSyncPoint=S_OKthen?begin??Flags:=FlagsorWM_SF_CLEANPOINT;?end;?ifMediaSample.IsDiscontinuity=S_OKthen?begin??
7、Flags:=FlagsorWM_SF_DISCONTINUITY;?end;?//LogFile.Write('VideoStarttime:'+inttostr(Starttime)+#9#9#9);?PushMgr.WriteBuffer(Starttime,Endtime,flags,true);?result:=NOERROR;end;procedureTPlayerVideoRenderFilter.OnReceiveFirstSample(?MediaSample:IMedia