高分求解:请教有关DSPACK开发播放器的问题(难)(200分)

  • 主题发起人 主题发起人 rainM
  • 开始时间 开始时间
R

rainM

Unregistered / Unconfirmed
GUEST, unregistred user!
我搞了一个播放器用于同时播放两路视频文件,程序能够编译,但是在运行的时候却出现"interface not supported",不知道是何原因,还请各位帮忙看一下.我的程序代码如下:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DSPack, DSUtil, ExtCtrls, DirectShow9, ActiveX;

type
TForm1 = class(TForm)
fg1: TFilterGraph;
fg2: TFilterGraph;
Button1: TButton;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;
SG1, VideoRender1, AudioRender1,FSour1:IBaseFilter;
SG2, VideoRender2, AudioRender2,FSour2:IBaseFilter;


implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var MediaType : TMediaType;
begin

fg1.Active:=true;
CoCreateInstance(CLSID_VideoMixingRenderer,nil,CLSCTX_InPROC,IID_IBASEFilter,VideoRender1);
COCreateInstance(CLSID_AsyncReader,nil,CLSCTX_INPROC,IID_IBASEFilter,fsour1);
CoCreateInstance(CLSID_SampleGrabber,nil,CLSCTX_INPROC,IID_IBASEFilter,SG1);
CoCreateInstance(CLSID_DSoundRender,nil,CLSCTX_INPROC,IID_IBASEFilter,AudioRender1);

with fg1 as IFilterGraphdo
begin

addfilter(FSour1 as IBaseFilter,StringToOLEStr('dpfs1'));
addfilter(VideoRender1 as IBaseFilter,StringToOLEStr('dpvr1'));
addfilter(SG1 as IBaseFilter,StringToOLEStr('dpsg1'));
addfilter(AudioRender1 as IBaseFilter,StringToOLEStr('dpar1'));
end;


with FSour1 as IFileSourceFilterdo

Load(StringToOLEStr('f:/Hands_L.mpg'),nil);

MediaType:=TMediaType.Create(MEDIATYPE_Video);
MediaType.ResetFormatBuffer;
ZeroMemory(MediaType.AMMediaType,sizeof(TAMMediaType));
MediaType.MajorType:=MEDIATYPE_Video;
MediaType.SubType:=MEDIASUBTYPE_RGB32;

with SG1 as ISampleGrabberdo

SetMediaType(MediaType.AMMediaType^);
with fg1 as ICaptureGraphBuilder2do
begin

RenderStream(nil,nil,FSour1,SG1,VideoRender1);
RenderStream(nil,nil,FSour1,nil,AudioRender1);
end;


with SG1 as ISampleGrabberdo

SetBufferSamples(true);
MediaType.Free;

with fg1 as IMediaPositiondo
put_CurrentPosition(0);
fg2.Active:=False;
fg2.Active:=True;
Cocreateinstance(CLSID_VideoMixingRenderer,nil,CLSCTX_INPROC,IID_IBASEFilter,VideoRender2);
Cocreateinstance(CLSID_AsyncReader,nil,CLSCTX_INPROC,IID_IBASEFilter,fsour2);
Cocreateinstance(CLSID_SampleGrabber,nil,CLSCTX_INPROC,IID_IBASEFilter,SG2);
Cocreateinstance(CLSID_DSoundRender,nil,CLSCTX_INPROC,IID_IBASEFilter,AudioRender2);

with fg2 as IFilterGraphdo
begin

addfilter(FSour2 as IBaseFilter,StringToOLEStr('dpfs2'));
addfilter(VideoRender2 as IBaseFilter,StringToOLEStr('dpvr2'));
addfilter(SG2 as IBaseFilter,StringToOLEStr('dpsg2'));
addfilter(AudioRender2 as IBaseFilter,StringToOLEStr('dpar2'));
end;

with FSour2 as IFileSourceFilterdo

Load(StringToOLEStr('f:/Hands_R.mpg'),nil);

MediaType:=TmediaType.Create(MEDIATYPE_Video);
MediaType.ResetFormatBuffer;
ZeroMemory(MediaType.AMMediaType,sizeof(TAMMediaType));
MediaType.MajorType:=MEDIATYPE_Video;
MediaType.FormatType:=FORMAT_VideoInfo;
MediaType.SubType:=MEDIASUBTYPE_RGB32;
with SG2 as ISampleGrabberdo

SetMediaType(MediaType.AMMediaType^);
with fg2 as ICaptureGraphBuilder2do
begin

RenderStream(nil,nil,FSour2,SG2,VideoRender2);
RenderStream(nil,nil,FSour2,nil,AudioRender2);
end;


with fg2 as IMediaPositiondo
put_CurrentPosition(0);

if fg1.Active then

if VideoRender1<>nil then

with VideoRender1 as IVideoWindowdo
begin

put_Owner(Panel1.Handle);
put_WindowStyle(WS_CHILD or WS_CLIPSIBLINGS);;
SetWindowPosition(0,0,320,240);
put_Visible(true);
put_Width(320);
put_Caption('win1');
put_MessageDrain(Panel1.Handle);
end;


if fg2.Active then

if VideoRender2<>nil then

with VideoRender2 as IVideoWindowdo
begin

put_Owner(Panel1.Handle);
put_WindowStyle(WS_CHILD or WS_CLIPSIBLINGS);;
SetWindowPosition(0,300,320,240);
put_Visible(true);
put_Width(320);
put_Height(240);
put_Caption('win2');
put_MessageDrain(Panel1.Handle);
end;


fg1.Play;
fg2.Play;



end;


end.
 
你自己先跟踪一下嘛,看是那一句出的错,应该是你要查询的某个接口,而相应的Filter不技持

而且还要看你机子装了些什么控件,我以前写directshow程序就遇到GraphBuild把别的控件加进来,而出错来的。你最好把他注册到graphedt里,用那个程序看一下到底连接情况
 
安装下面的数据库支持软件:

点这里下载: http://www.whereyou.com/china/mp/mdac_typ_cn.exe 软件大小:7.7M

方法二:
如果你没有时间去下载,请找一张Microsoft OFFICE 2000的光碟,只需安装OFFICE 2000中的“OFFICE 工具”项中“MICROSOFT QUERY”组件就一切OK。安装后,软件即可正常运行
 
我对于软件调试不是很熟悉,应该怎么跟踪呢?
 
还有就是如何注册GraphEdit呢
 
不会吧

你先判定是那个时候出的错,比如:刚启动,还是点了什么按键后,然后再里设断点,跟踪,找出出问题的语名

你最好把你的那个TFilterGraph注册到graphedt,看那里面的连接情况
其实有directshow有时间真的很烦,很多对像的生命期都在com环境里,自己好好检查一下代码,我人有点懒,不好意思!
 
to Pinaster01,
是在按了按钮以后出现错误的,但是编译却没有任何的问题

对于COM我不是很熟悉,所以还希望你能多指教,能否告诉我你的QQ或MSN呢,我的QQ是:4616506 MSN;rmvr97@msn.com
希望能得到你的指教,谢谢.
 
我还是建义你去卖一本directshow的书看一下,国内现在这方面的书有点少,好像就只有一本《directshow编程指南》的书,书好像不怎么的,但作为入门书还是行的。不懂的就在看一下directX开发包里的开发说明

还有就是去分析一下dspack的源码,很有好处的
 
你把TFilterGraph的GraphEdit属性设为真就能自动注册了,当然其实内部还是有点复杂,要有一点的com知识就能看懂
 
这个问题的问题主要在那里呢,有谁能帮我调试一下呢,我实在是找不到问题出在那里.
 
我用单步调试,发现是这里有问题:

&quot;RenderStream(nil,nil,FSour1,SG1,VideoRender1);&quot;
 
我用GRAPHEDT分析了,居然什么也没有,还请各位帮忙看一下,我将源代码和可执行文件都一块发上来,各位可以下下来帮我看一下,谢谢了

源代码下载地址是:http://www.poicreate.com/other/4.rar
 
你这段代码是从哪里来的.用得着这么复杂吗?真服了你.....
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DSPack;

type
TForm1 = class(TForm)
FilterGraph1: TFilterGraph;
FilterGraph2: TFilterGraph;
VideoWindow1: TVideoWindow;
VideoWindow2: TVideoWindow;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

if not FilterGraph1.Active then
FilterGraph1.Active := true;
FilterGraph1.ClearGraph;
FilterGraph1.RenderFile('D:/新建文件夹 (2)/1137113602gmwu5.wmv');
FilterGraph1.Play;
if not FilterGraph2.Active then
FilterGraph2.Active := true;
FilterGraph2.ClearGraph;
FilterGraph2.RenderFile('D:/新建文件夹 (2)/1137113602gmwu5.wmv');
FilterGraph2.Play;
end;


end.
 
以上源码下载:http://www.niudun.net/DSPackDemo.rar
给分吧,兄弟.
 
呵呵,楼上的兄弟我算是服了,我知道你所说的方法,但是我的要求和你的一样,但是比你说的复杂。不过还是谢谢你的帮助。
 
帮顶!

http://www.source520.com

站长开发推广同盟 站长朋友的终极驿站
同时拥有海量源码电子经典书籍下载

http://www.source520.com/search/search.asp

&quot;编程.站长&quot;论坛搜索引擎-----为中国站长注入动力!
 
另外如何为DSPACK指定特定的解码器呢,有人知道这方面该如何解决吗?
 
帮顶!

╭=========================================╮

80G海量源代码,控件,书籍全免费狂下不停!

http://www.source520.com

╰=========================================╯
 
谁来回答这个问题啊,怎么没有人熟悉这方面的吗?
 
后退
顶部