DTXManiaXG(Ver.K)4.00Series
Revisão | 13d85593e5ce18fe505639a500945ab1448f0cb8 (tree) |
---|---|
Hora | 2016-12-10 10:35:43 |
Autor | kairera0467 <gennsou76573@gmai...> |
Commiter | kairera0467 |
#36708 StageClear演出、FCEXC演出のクラスを追加。
#xxxxx MemoryRendererでDirectShow動画を扱えるようにした。
@@ -144,6 +144,8 @@ | ||
144 | 144 | <Compile Include="コード\ステージ\07.演奏\CAct演奏Combo共通.cs" /> |
145 | 145 | <Compile Include="コード\ステージ\07.演奏\CAct演奏Danger共通.cs" /> |
146 | 146 | <Compile Include="コード\ステージ\07.演奏\CAct演奏RGB共通.cs" /> |
147 | + <Compile Include="コード\ステージ\07.演奏\CAct演奏FCEXC演出.cs" /> | |
148 | + <Compile Include="コード\ステージ\07.演奏\CAct演奏StageClear.cs" /> | |
147 | 149 | <Compile Include="コード\ステージ\07.演奏\CAct演奏WailingBonus共通.cs" /> |
148 | 150 | <Compile Include="コード\ステージ\07.演奏\CAct演奏ゲージ共通.cs" /> |
149 | 151 | <Compile Include="コード\ステージ\07.演奏\CAct演奏スクロール速度.cs" /> |
@@ -0,0 +1,80 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Text; | |
4 | +using System.Drawing; | |
5 | +using FDK; | |
6 | + | |
7 | +namespace DTXMania | |
8 | +{ | |
9 | + internal class CAct演奏FCEXC演出 : CActivity | |
10 | + { | |
11 | + //FC、EXC演出をするメソッド。 | |
12 | + //FIFOメソッドの拡張 | |
13 | + | |
14 | + // メソッド | |
15 | + | |
16 | + public void t開始() | |
17 | + { | |
18 | + this.counter = new CCounter( 0, 100, 5, CDTXMania.Timer ); | |
19 | + } | |
20 | + public void t演出終了() | |
21 | + { | |
22 | + this.counter.n現在の値 = this.counter.n終了値; | |
23 | + } | |
24 | + | |
25 | + // CActivity 実装 | |
26 | + | |
27 | + public override void On非活性化() | |
28 | + { | |
29 | + if( !base.b活性化してない ) | |
30 | + { | |
31 | + CDTXMania.tテクスチャの解放( ref this.tx黒タイル64x64 ); | |
32 | + base.On非活性化(); | |
33 | + } | |
34 | + } | |
35 | + public override void OnManagedリソースの作成() | |
36 | + { | |
37 | + if( !base.b活性化してない ) | |
38 | + { | |
39 | + this.tx黒タイル64x64 = CDTXMania.tテクスチャの生成( CSkin.Path( @"Graphics\Tile black 64x64.png" ), false ); | |
40 | + base.OnManagedリソースの作成(); | |
41 | + } | |
42 | + } | |
43 | + public override int On進行描画() | |
44 | + { | |
45 | + if( base.b活性化してない || ( this.counter == null ) ) | |
46 | + { | |
47 | + return 0; | |
48 | + } | |
49 | + this.counter.t進行(); | |
50 | + | |
51 | + if( this.tx黒タイル64x64 != null ) | |
52 | + { | |
53 | + this.tx黒タイル64x64.n透明度 = 0; | |
54 | + for( int i = 0; i <= ( SampleFramework.GameWindowSize.Width / 64 ); i++ ) // #23510 2010.10.31 yyagi: change "clientSize.Width" to "640" to fix FIFO drawing size | |
55 | + { | |
56 | + for( int j = 0; j <= (SampleFramework.GameWindowSize.Height / 64 ); j++ ) // #23510 2010.10.31 yyagi: change "clientSize.Height" to "480" to fix FIFO drawing size | |
57 | + { | |
58 | + this.tx黒タイル64x64.t2D描画( CDTXMania.app.Device, i * 64, j * 64 ); | |
59 | + } | |
60 | + } | |
61 | + } | |
62 | + if( this.counter.n現在の値 != 100 ) | |
63 | + { | |
64 | + return 0; | |
65 | + } | |
66 | + return 1; | |
67 | + } | |
68 | + | |
69 | + | |
70 | + // その他 | |
71 | + | |
72 | + #region [ private ] | |
73 | + //----------------- | |
74 | + private CCounter counter; | |
75 | + private CTexture tx黒タイル64x64; | |
76 | + private CTexture tx描画用; | |
77 | + //----------------- | |
78 | + #endregion | |
79 | + } | |
80 | +} |
@@ -0,0 +1,86 @@ | ||
1 | +using DirectShowLib; | |
2 | +using System; | |
3 | +using System.Collections.Generic; | |
4 | +using System.Text; | |
5 | +using System.Drawing; | |
6 | +using FDK; | |
7 | + | |
8 | +namespace DTXMania | |
9 | +{ | |
10 | + internal class CAct演奏StageClear : CActivity | |
11 | + { | |
12 | + // メソッド | |
13 | + | |
14 | + public void t開始() | |
15 | + { | |
16 | + this.counter = new CCounter( 0, 200, 5, CDTXMania.Timer ); | |
17 | + } | |
18 | + public void t完了() | |
19 | + { | |
20 | + this.counter.n現在の値 = this.counter.n終了値; | |
21 | + } | |
22 | + | |
23 | + // CActivity 実装 | |
24 | + | |
25 | + public override void On非活性化() | |
26 | + { | |
27 | + if( !base.b活性化してない ) | |
28 | + { | |
29 | + CDTXMania.tテクスチャの解放( ref this.tx描画用 ); | |
30 | + CDTXMania.t安全にDisposeする( ref this.dsStageClear ); | |
31 | + base.On非活性化(); | |
32 | + } | |
33 | + } | |
34 | + public override void OnManagedリソースの作成() | |
35 | + { | |
36 | + if( !base.b活性化してない ) | |
37 | + { | |
38 | + this.tx描画用 = new CTexture( CDTXMania.app.Device, 1280, 720, CDTXMania.TextureFormat ); | |
39 | + this.dsStageClear = CDTXMania.t失敗してもスキップ可能なDirectShowを生成する( CSkin.Path( @"Graphics\7_StageClear.mp4" ), CDTXMania.app.WindowHandle, true, true ); | |
40 | + base.OnManagedリソースの作成(); | |
41 | + } | |
42 | + } | |
43 | + public override int On進行描画() | |
44 | + { | |
45 | + if( base.b活性化してない || ( this.counter == null ) ) | |
46 | + { | |
47 | + return 0; | |
48 | + } | |
49 | + if( base.b初めての進行描画 ) | |
50 | + { | |
51 | + CDTXMania.Skin.soundステージクリア音.t再生する(); | |
52 | + base.b初めての進行描画 = true; | |
53 | + } | |
54 | + this.counter.t進行(); | |
55 | + | |
56 | + | |
57 | + | |
58 | + if( CDTXMania.Skin.soundステージクリア音.b再生中 ) | |
59 | + { | |
60 | + return 0; | |
61 | + } | |
62 | + | |
63 | + if( CDTXMania.Skin.soundステージクリア音 == null ) | |
64 | + { | |
65 | + if( this.counter.b終了値に達した ) | |
66 | + { | |
67 | + return 1; | |
68 | + } | |
69 | + } | |
70 | + return 1; | |
71 | + } | |
72 | + | |
73 | + | |
74 | + // その他 | |
75 | + | |
76 | + #region [ private ] | |
77 | + //----------------- | |
78 | + private CCounter counter; | |
79 | + private EFIFOモード mode; | |
80 | + private CTexture tx白タイル64x64; | |
81 | + private CTexture tx描画用; | |
82 | + private CDirectShow dsStageClear; | |
83 | + //----------------- | |
84 | + #endregion | |
85 | + } | |
86 | +} |
@@ -668,6 +668,7 @@ namespace DTXMania | ||
668 | 668 | protected CAct演奏演奏情報 actPlayInfo; |
669 | 669 | protected CAct演奏RGB共通 actRGB; |
670 | 670 | public CAct演奏スコア共通 actScore; |
671 | + protected CAct演奏StageClear actStageClear; | |
671 | 672 | protected CAct演奏ステージ失敗 actStageFailed; |
672 | 673 | protected CAct演奏ステータスパネル共通 actStatusPanels; |
673 | 674 | protected CAct演奏WailingBonus共通 actWailingBonus; |
@@ -3498,9 +3499,8 @@ namespace DTXMania | ||
3498 | 3499 | return true; |
3499 | 3500 | } |
3500 | 3501 | break; |
3501 | - | |
3502 | 3502 | case CStage.Eフェーズ.演奏_STAGE_CLEAR_フェードアウト: |
3503 | - if ( this.actFOClear.On進行描画() == 0 ) | |
3503 | + if ( this.actFO.On進行描画() == 0 ) | |
3504 | 3504 | { |
3505 | 3505 | break; |
3506 | 3506 | } |
@@ -1731,12 +1731,16 @@ for (int i = 0; i < 3; i++) { | ||
1731 | 1731 | #endregion |
1732 | 1732 | public static CDirectShow t失敗してもスキップ可能なDirectShowを生成する( string fileName, IntPtr hWnd, bool bオーディオレンダラなし ) |
1733 | 1733 | { |
1734 | + return t失敗してもスキップ可能なDirectShowを生成する( fileName, hWnd, bオーディオレンダラなし, false ); | |
1735 | + } | |
1736 | + public static CDirectShow t失敗してもスキップ可能なDirectShowを生成する( string fileName, IntPtr hWnd, bool bオーディオレンダラなし, bool bMemoryRenderer ) | |
1737 | + { | |
1734 | 1738 | CDirectShow ds = null; |
1735 | 1739 | if( File.Exists( fileName ) ) |
1736 | 1740 | { |
1737 | 1741 | try |
1738 | 1742 | { |
1739 | - ds = new CDirectShow( fileName, hWnd, bオーディオレンダラなし ); | |
1743 | + ds = new CDirectShow( fileName, hWnd, bMemoryRenderer, bオーディオレンダラなし ); | |
1740 | 1744 | } |
1741 | 1745 | catch( FileNotFoundException ) |
1742 | 1746 | { |
@@ -91,7 +91,7 @@ namespace FDK | ||
91 | 91 | |
92 | 92 | // Null レンダラに接続しないとウィンドウが表示される。 |
93 | 93 | // また、レンダリングを行わないため処理速度を向上できる。 |
94 | - CDirectShow.ConnectNullRendererFromSampleGrabber(builder, grabber as IBaseFilter); | |
94 | + CDirectShow.ConnectNullRendererFromSampleGrabber(builder, grabber as IBaseFilter, false); | |
95 | 95 | CDirectShow.tグラフを解析しデバッグ出力する(builder); |
96 | 96 | |
97 | 97 | IVideoWindow videoWindow = builder as IVideoWindow; |
@@ -249,7 +249,7 @@ namespace FDK | ||
249 | 249 | public CDirectShow() |
250 | 250 | { |
251 | 251 | } |
252 | - public CDirectShow( string fileName, IntPtr hWnd, bool bオーディオレンダラなし ) | |
252 | + public CDirectShow( string fileName, IntPtr hWnd, bool bMemoryRenderer, bool bオーディオレンダラなし ) | |
253 | 253 | { |
254 | 254 | // 初期化。 |
255 | 255 |
@@ -328,10 +328,23 @@ namespace FDK | ||
328 | 328 | |
329 | 329 | |
330 | 330 | // 音声のみ? |
331 | - | |
331 | + if( bMemoryRenderer ) | |
332 | 332 | { |
333 | 333 | IBaseFilter videoRenderer; |
334 | 334 | IPin videoInputPin; |
335 | + CDirectShow.tビデオレンダラとその入力ピンを探して返す( this.graphBuilder, out videoRenderer, out videoInputPin ); | |
336 | + if( videoRenderer == null ) | |
337 | + this.b音声のみ = true; | |
338 | + else | |
339 | + { | |
340 | + C共通.tCOMオブジェクトを解放する( ref videoInputPin ); | |
341 | + C共通.tCOMオブジェクトを解放する( ref videoRenderer ); | |
342 | + } | |
343 | + } | |
344 | + else | |
345 | + { | |
346 | + IBaseFilter videoRenderer; | |
347 | + IPin videoInputPin; | |
335 | 348 | IBaseFilter audioRenderer; |
336 | 349 | IPin audioInputPin; |
337 | 350 | CDirectShow.SearchMMRenderers( this.graphBuilder, out videoRenderer, out videoInputPin, out audioRenderer, out audioInputPin ); |
@@ -346,7 +359,7 @@ namespace FDK | ||
346 | 359 | C共通.tCOMオブジェクトを解放する(ref audioInputPin); |
347 | 360 | C共通.tCOMオブジェクトを解放する(ref audioRenderer); |
348 | 361 | } |
349 | - } | |
362 | + } | |
350 | 363 | |
351 | 364 | |
352 | 365 | // イメージ情報を取得。 |
@@ -841,7 +854,7 @@ namespace FDK | ||
841 | 854 | C共通.tCOMオブジェクトを解放する( ref audioRenderer ); |
842 | 855 | } |
843 | 856 | } |
844 | - public static void ConnectNullRendererFromSampleGrabber(IGraphBuilder graphBuilder, IBaseFilter sampleGrabber) | |
857 | + public static void ConnectNullRendererFromSampleGrabber(IGraphBuilder graphBuilder, IBaseFilter sampleGrabber, bool bMemoryRenderer ) | |
845 | 858 | { |
846 | 859 | int hr = 0; |
847 | 860 | IBaseFilter videoRenderer = null; |
@@ -849,79 +862,128 @@ namespace FDK | ||
849 | 862 | IBaseFilter audioRenderer = null; |
850 | 863 | IPin audioRendererInputPin = null; |
851 | 864 | IPin connectedOutputPin = null; |
865 | + IPin rendererConnectedOutputPin = null; | |
852 | 866 | IPin nullRendererInputPin = null; |
853 | 867 | IPin grabberOutputPin = null; |
854 | 868 | IPin grabberOutputConnectedPin = null; |
855 | 869 | |
856 | 870 | try |
857 | 871 | { |
858 | - // videoRenderer を探す。 | |
859 | - CDirectShow.SearchMMRenderers(graphBuilder, out videoRenderer, out videoRendererInputPin, out audioRenderer, out audioRendererInputPin); | |
860 | - if (videoRenderer != null && audioRendererInputPin != null) | |
861 | - { | |
862 | - // 既存のレンダラにつながっているピン対を取得 | |
863 | - hr = videoRendererInputPin.ConnectedTo(out connectedOutputPin); | |
864 | - DsError.ThrowExceptionForHR(hr); | |
865 | - | |
866 | - // それらを切断。前段の出力ピンとビデオレンダラの入力ピンを切断する。双方向から切断しないとグラフから切り離されないので注意。 | |
867 | - hr = videoRendererInputPin.Disconnect(); | |
868 | - DsError.ThrowExceptionForHR(hr); | |
869 | - hr = connectedOutputPin.Disconnect(); | |
870 | - DsError.ThrowExceptionForHR(hr); | |
871 | - | |
872 | - // ビデオレンダラをグラフから除去し、ヌルレンダラを追加 | |
873 | - hr = graphBuilder.RemoveFilter(videoRenderer); | |
874 | - DsError.ThrowExceptionForHR(hr); | |
875 | - IBaseFilter nullRenderer = new NullRenderer() as IBaseFilter; | |
876 | - hr = graphBuilder.AddFilter(nullRenderer, "Video Null Renderer"); | |
877 | - DsError.ThrowExceptionForHR(hr); | |
878 | - | |
879 | - // nullRenderer の入力ピンを探す。 | |
880 | - hr = nullRenderer.FindPin("In", out nullRendererInputPin); | |
881 | - DsError.ThrowExceptionForHR(hr); | |
882 | - hr = nullRendererInputPin.Disconnect(); | |
883 | - DsError.ThrowExceptionForHR(hr); | |
884 | - | |
885 | - // グラバの Out と Null Renderer の In を接続する。 | |
886 | - hr = sampleGrabber.FindPin("Out", out grabberOutputPin); | |
887 | - DsError.ThrowExceptionForHR(hr); | |
888 | - hr = grabberOutputPin.ConnectedTo(out grabberOutputConnectedPin); | |
889 | - DsError.ThrowExceptionForHR(hr); | |
890 | - hr = grabberOutputConnectedPin.Disconnect(); | |
891 | - DsError.ThrowExceptionForHR(hr); | |
892 | - hr = grabberOutputPin.Disconnect(); | |
893 | - DsError.ThrowExceptionForHR(hr); | |
894 | - hr = grabberOutputPin.Connect(nullRendererInputPin, null); | |
895 | - DsError.ThrowExceptionForHR(hr); | |
896 | - } | |
897 | - | |
898 | - if( audioRenderer != null && audioRendererInputPin != null ) | |
899 | - { | |
900 | - C共通.tCOMオブジェクトを解放する(ref connectedOutputPin); | |
901 | - | |
902 | - // 既存のレンダラにつながっているピン対を取得 | |
903 | - hr = audioRendererInputPin.ConnectedTo(out connectedOutputPin); | |
904 | - DsError.ThrowExceptionForHR(hr); | |
905 | - | |
906 | - // それらを切断。前段の出力ピンとビデオレンダラの入力ピンを切断する。双方向から切断しないとグラフから切り離されないので注意。 | |
907 | - hr = audioRendererInputPin.Disconnect(); | |
908 | - DsError.ThrowExceptionForHR(hr); | |
909 | - hr = connectedOutputPin.Disconnect(); | |
910 | - DsError.ThrowExceptionForHR(hr); | |
911 | - | |
912 | - // ビデオレンダラをグラフから除去し、ヌルレンダラを追加 | |
913 | - hr = graphBuilder.RemoveFilter(audioRenderer); | |
914 | - DsError.ThrowExceptionForHR(hr); | |
915 | - IBaseFilter nullRenderer = new NullRenderer() as IBaseFilter; | |
916 | - hr = graphBuilder.AddFilter(nullRenderer, "Audio Null Renderer"); | |
917 | - DsError.ThrowExceptionForHR(hr); | |
918 | - | |
919 | - C共通.tCOMオブジェクトを解放する(ref nullRendererInputPin); | |
920 | - hr = nullRenderer.FindPin("In", out nullRendererInputPin); | |
921 | - DsError.ThrowExceptionForHR(hr); | |
922 | - hr = connectedOutputPin.Connect(nullRendererInputPin, null); | |
923 | - DsError.ThrowExceptionForHR(hr); | |
924 | - } | |
872 | + if( bMemoryRenderer ) | |
873 | + { | |
874 | + // videoRenderer を探す。 | |
875 | + CDirectShow.tビデオレンダラとその入力ピンを探して返す(graphBuilder, out videoRenderer, out videoRendererInputPin); | |
876 | + if(videoRenderer==null || videoRendererInputPin ==null) | |
877 | + { | |
878 | + return; | |
879 | + } | |
880 | + // 既存のレンダラにつながっているピン対を取得 | |
881 | + hr = videoRendererInputPin.ConnectedTo(out connectedOutputPin); | |
882 | + DsError.ThrowExceptionForHR(hr); | |
883 | + hr = videoRendererInputPin.ConnectedTo(out rendererConnectedOutputPin); | |
884 | + DsError.ThrowExceptionForHR(hr); | |
885 | + | |
886 | + // それらを切断。前段の出力ピンとビデオレンダラの入力ピンを切断する。双方向から切断しないとグラフから切り離されないので注意。 | |
887 | + hr = videoRendererInputPin.Disconnect(); | |
888 | + DsError.ThrowExceptionForHR(hr); | |
889 | + hr = connectedOutputPin.Disconnect(); | |
890 | + DsError.ThrowExceptionForHR(hr); | |
891 | + | |
892 | + // ビデオレンダラをグラフから除去し、ヌルレンダラを追加 | |
893 | + hr = graphBuilder.RemoveFilter(videoRenderer); | |
894 | + DsError.ThrowExceptionForHR(hr); | |
895 | + IBaseFilter nullRenderer = new NullRenderer() as IBaseFilter; | |
896 | + hr = graphBuilder.AddFilter(nullRenderer, "Null Renderer"); | |
897 | + DsError.ThrowExceptionForHR(hr); | |
898 | + | |
899 | + // nullRenderer の入力ピンを探す。 | |
900 | + hr = nullRenderer.FindPin("In", out nullRendererInputPin); | |
901 | + DsError.ThrowExceptionForHR(hr); | |
902 | + hr = nullRendererInputPin.Disconnect(); | |
903 | + DsError.ThrowExceptionForHR(hr); | |
904 | + | |
905 | + // グラバの Out と Null Renderer の In を接続する。 | |
906 | + hr = sampleGrabber.FindPin("Out", out grabberOutputPin); | |
907 | + DsError.ThrowExceptionForHR(hr); | |
908 | + hr = grabberOutputPin.ConnectedTo(out grabberOutputConnectedPin); | |
909 | + DsError.ThrowExceptionForHR(hr); | |
910 | + hr = grabberOutputConnectedPin.Disconnect(); | |
911 | + DsError.ThrowExceptionForHR(hr); | |
912 | + hr = grabberOutputPin.Disconnect(); | |
913 | + DsError.ThrowExceptionForHR(hr); | |
914 | + hr = grabberOutputPin.Connect(nullRendererInputPin, null); | |
915 | + DsError.ThrowExceptionForHR(hr); | |
916 | + } | |
917 | + else | |
918 | + { | |
919 | + // videoRenderer を探す。 | |
920 | + CDirectShow.SearchMMRenderers(graphBuilder, out videoRenderer, out videoRendererInputPin, out audioRenderer, out audioRendererInputPin); | |
921 | + if (videoRenderer != null && audioRendererInputPin != null) | |
922 | + { | |
923 | + // 既存のレンダラにつながっているピン対を取得 | |
924 | + hr = videoRendererInputPin.ConnectedTo(out connectedOutputPin); | |
925 | + DsError.ThrowExceptionForHR(hr); | |
926 | + | |
927 | + // それらを切断。前段の出力ピンとビデオレンダラの入力ピンを切断する。双方向から切断しないとグラフから切り離されないので注意。 | |
928 | + hr = videoRendererInputPin.Disconnect(); | |
929 | + DsError.ThrowExceptionForHR(hr); | |
930 | + hr = connectedOutputPin.Disconnect(); | |
931 | + DsError.ThrowExceptionForHR(hr); | |
932 | + | |
933 | + // ビデオレンダラをグラフから除去し、ヌルレンダラを追加 | |
934 | + hr = graphBuilder.RemoveFilter(videoRenderer); | |
935 | + DsError.ThrowExceptionForHR(hr); | |
936 | + IBaseFilter nullRenderer = new NullRenderer() as IBaseFilter; | |
937 | + hr = graphBuilder.AddFilter(nullRenderer, "Video Null Renderer"); | |
938 | + DsError.ThrowExceptionForHR(hr); | |
939 | + | |
940 | + // nullRenderer の入力ピンを探す。 | |
941 | + hr = nullRenderer.FindPin("In", out nullRendererInputPin); | |
942 | + DsError.ThrowExceptionForHR(hr); | |
943 | + hr = nullRendererInputPin.Disconnect(); | |
944 | + DsError.ThrowExceptionForHR(hr); | |
945 | + | |
946 | + // グラバの Out と Null Renderer の In を接続する。 | |
947 | + hr = sampleGrabber.FindPin("Out", out grabberOutputPin); | |
948 | + DsError.ThrowExceptionForHR(hr); | |
949 | + hr = grabberOutputPin.ConnectedTo(out grabberOutputConnectedPin); | |
950 | + DsError.ThrowExceptionForHR(hr); | |
951 | + hr = grabberOutputConnectedPin.Disconnect(); | |
952 | + DsError.ThrowExceptionForHR(hr); | |
953 | + hr = grabberOutputPin.Disconnect(); | |
954 | + DsError.ThrowExceptionForHR(hr); | |
955 | + hr = grabberOutputPin.Connect(nullRendererInputPin, null); | |
956 | + DsError.ThrowExceptionForHR(hr); | |
957 | + } | |
958 | + | |
959 | + if( audioRenderer != null && audioRendererInputPin != null ) | |
960 | + { | |
961 | + C共通.tCOMオブジェクトを解放する(ref connectedOutputPin); | |
962 | + | |
963 | + // 既存のレンダラにつながっているピン対を取得 | |
964 | + hr = audioRendererInputPin.ConnectedTo(out connectedOutputPin); | |
965 | + DsError.ThrowExceptionForHR(hr); | |
966 | + | |
967 | + // それらを切断。前段の出力ピンとビデオレンダラの入力ピンを切断する。双方向から切断しないとグラフから切り離されないので注意。 | |
968 | + hr = audioRendererInputPin.Disconnect(); | |
969 | + DsError.ThrowExceptionForHR(hr); | |
970 | + hr = connectedOutputPin.Disconnect(); | |
971 | + DsError.ThrowExceptionForHR(hr); | |
972 | + | |
973 | + // ビデオレンダラをグラフから除去し、ヌルレンダラを追加 | |
974 | + hr = graphBuilder.RemoveFilter(audioRenderer); | |
975 | + DsError.ThrowExceptionForHR(hr); | |
976 | + IBaseFilter nullRenderer = new NullRenderer() as IBaseFilter; | |
977 | + hr = graphBuilder.AddFilter(nullRenderer, "Audio Null Renderer"); | |
978 | + DsError.ThrowExceptionForHR(hr); | |
979 | + | |
980 | + C共通.tCOMオブジェクトを解放する(ref nullRendererInputPin); | |
981 | + hr = nullRenderer.FindPin("In", out nullRendererInputPin); | |
982 | + DsError.ThrowExceptionForHR(hr); | |
983 | + hr = connectedOutputPin.Connect(nullRendererInputPin, null); | |
984 | + DsError.ThrowExceptionForHR(hr); | |
985 | + } | |
986 | + } | |
925 | 987 | } |
926 | 988 | finally |
927 | 989 | { |
@@ -936,6 +998,50 @@ namespace FDK | ||
936 | 998 | } |
937 | 999 | } |
938 | 1000 | |
1001 | + public static void tビデオレンダラをグラフから除去する( IGraphBuilder graphBuilder ) | |
1002 | + { | |
1003 | + int hr = 0; | |
1004 | + | |
1005 | + IBaseFilter videoRenderer = null; | |
1006 | + IPin renderInputPin = null; | |
1007 | + IPin connectedOutputPin = null; | |
1008 | + | |
1009 | + try | |
1010 | + { | |
1011 | + // videoRenderer を探す。 | |
1012 | + | |
1013 | + CDirectShow.tビデオレンダラとその入力ピンを探して返す( graphBuilder, out videoRenderer, out renderInputPin ); | |
1014 | + if( videoRenderer == null || renderInputPin == null ) | |
1015 | + return; // なかった | |
1016 | + | |
1017 | + #region [ renderInputPin へ接続している前段の出力ピン connectedOutputPin を探す。 ] | |
1018 | + //----------------- | |
1019 | + renderInputPin.ConnectedTo( out connectedOutputPin ); | |
1020 | + //----------------- | |
1021 | + #endregion | |
1022 | + | |
1023 | + if( connectedOutputPin == null ) | |
1024 | + return; // なかった | |
1025 | + | |
1026 | + | |
1027 | + // 前段の出力ピンとビデオレンダラの入力ピンを切断する。双方向から切断しないとグラフから切り離されないので注意。 | |
1028 | + | |
1029 | + renderInputPin.Disconnect(); | |
1030 | + connectedOutputPin.Disconnect(); | |
1031 | + | |
1032 | + | |
1033 | + // ビデオレンダラをグラフから除去。 | |
1034 | + | |
1035 | + graphBuilder.RemoveFilter( videoRenderer ); | |
1036 | + } | |
1037 | + finally | |
1038 | + { | |
1039 | + C共通.tCOMオブジェクトを解放する( ref connectedOutputPin ); | |
1040 | + C共通.tCOMオブジェクトを解放する( ref renderInputPin ); | |
1041 | + C共通.tCOMオブジェクトを解放する( ref videoRenderer ); | |
1042 | + } | |
1043 | + } | |
1044 | + | |
939 | 1045 | private static IPin t最初の入力ピンを探して返す( IBaseFilter baseFilter ) |
940 | 1046 | { |
941 | 1047 | int hr = 0; |
@@ -980,6 +1086,159 @@ namespace FDK | ||
980 | 1086 | |
981 | 1087 | return firstInputPin; |
982 | 1088 | } |
1089 | + | |
1090 | + private static void tビデオレンダラとその入力ピンを探して返す( IFilterGraph graph, out IBaseFilter videoRenderer, out IPin inputPin ) | |
1091 | + { | |
1092 | + int hr = 0; | |
1093 | + string strフィルタ名 = null; | |
1094 | + string strピンID = null; | |
1095 | + | |
1096 | + | |
1097 | + // ビデオレンダラと入力ピンを探し、そのフィルタ名とピンIDを控える。 | |
1098 | + | |
1099 | + IEnumFilters eFilters; | |
1100 | + hr = graph.EnumFilters( out eFilters ); | |
1101 | + DsError.ThrowExceptionForHR( hr ); | |
1102 | + try | |
1103 | + { | |
1104 | + var filters = new IBaseFilter[ 1 ]; | |
1105 | + while( eFilters.Next( 1, filters, IntPtr.Zero ) == CWin32.S_OK ) | |
1106 | + { | |
1107 | + try | |
1108 | + { | |
1109 | + #region [ 出力ピンがない(レンダラである)ことを確認する。] | |
1110 | + //----------------- | |
1111 | + IEnumPins ePins; | |
1112 | + bool b出力ピンがある = false; | |
1113 | + | |
1114 | + hr = filters[ 0 ].EnumPins( out ePins ); | |
1115 | + DsError.ThrowExceptionForHR( hr ); | |
1116 | + try | |
1117 | + { | |
1118 | + var pins = new IPin[ 1 ]; | |
1119 | + while( ePins.Next( 1, pins, IntPtr.Zero ) == CWin32.S_OK ) | |
1120 | + { | |
1121 | + try | |
1122 | + { | |
1123 | + if( b出力ピンがある ) | |
1124 | + continue; | |
1125 | + | |
1126 | + PinDirection dir; | |
1127 | + hr = pins[ 0 ].QueryDirection( out dir ); | |
1128 | + DsError.ThrowExceptionForHR( hr ); | |
1129 | + if( dir == PinDirection.Output ) | |
1130 | + b出力ピンがある = true; | |
1131 | + } | |
1132 | + finally | |
1133 | + { | |
1134 | + C共通.tCOMオブジェクトを解放する( ref pins[ 0 ] ); | |
1135 | + } | |
1136 | + } | |
1137 | + } | |
1138 | + finally | |
1139 | + { | |
1140 | + C共通.tCOMオブジェクトを解放する( ref ePins ); | |
1141 | + } | |
1142 | + | |
1143 | + if( b出力ピンがある ) | |
1144 | + continue; // 次のフィルタへ | |
1145 | + | |
1146 | + //----------------- | |
1147 | + #endregion | |
1148 | + #region [ 接続中の入力ピンが MEDIATYPE_Video に対応していたら、フィルタ名とピンIDを取得する。] | |
1149 | + //----------------- | |
1150 | + hr = filters[ 0 ].EnumPins( out ePins ); | |
1151 | + DsError.ThrowExceptionForHR( hr ); | |
1152 | + try | |
1153 | + { | |
1154 | + var pins = new IPin[ 1 ]; | |
1155 | + while( ePins.Next( 1, pins, IntPtr.Zero ) == CWin32.S_OK ) | |
1156 | + { | |
1157 | + try | |
1158 | + { | |
1159 | + if( !string.IsNullOrEmpty( strフィルタ名 ) ) | |
1160 | + continue; | |
1161 | + | |
1162 | + var mediaType = new AMMediaType(); | |
1163 | + | |
1164 | + #region [ 現在接続中の MediaType を取得。つながってなければ次のピンへ。] | |
1165 | + //----------------- | |
1166 | + hr = pins[ 0 ].ConnectionMediaType( mediaType ); | |
1167 | + if( hr == CWin32.VFW_E_NOT_CONNECTED ) | |
1168 | + continue; // つながってない | |
1169 | + DsError.ThrowExceptionForHR( hr ); | |
1170 | + //----------------- | |
1171 | + #endregion | |
1172 | + | |
1173 | + try | |
1174 | + { | |
1175 | + if( mediaType.majorType.Equals( MediaType.Video ) ) | |
1176 | + { | |
1177 | + #region [ フィルタ名取得!] | |
1178 | + //----------------- | |
1179 | + FilterInfo filterInfo; | |
1180 | + hr = filters[ 0 ].QueryFilterInfo( out filterInfo ); | |
1181 | + DsError.ThrowExceptionForHR( hr ); | |
1182 | + strフィルタ名 = filterInfo.achName; | |
1183 | + C共通.tCOMオブジェクトを解放する( ref filterInfo.pGraph ); | |
1184 | + //----------------- | |
1185 | + #endregion | |
1186 | + #region [ ピンID取得!] | |
1187 | + //----------------- | |
1188 | + hr = pins[ 0 ].QueryId( out strピンID ); | |
1189 | + DsError.ThrowExceptionForHR( hr ); | |
1190 | + //----------------- | |
1191 | + #endregion | |
1192 | + | |
1193 | + continue; // 次のピンへ。 | |
1194 | + } | |
1195 | + } | |
1196 | + finally | |
1197 | + { | |
1198 | + DsUtils.FreeAMMediaType( mediaType ); | |
1199 | + } | |
1200 | + } | |
1201 | + finally | |
1202 | + { | |
1203 | + C共通.tCOMオブジェクトを解放する( ref pins[ 0 ] ); | |
1204 | + } | |
1205 | + } | |
1206 | + } | |
1207 | + finally | |
1208 | + { | |
1209 | + C共通.tCOMオブジェクトを解放する( ref ePins ); | |
1210 | + } | |
1211 | + | |
1212 | + //----------------- | |
1213 | + #endregion | |
1214 | + } | |
1215 | + finally | |
1216 | + { | |
1217 | + C共通.tCOMオブジェクトを解放する( ref filters[ 0 ] ); | |
1218 | + } | |
1219 | + } | |
1220 | + } | |
1221 | + finally | |
1222 | + { | |
1223 | + C共通.tCOMオブジェクトを解放する( ref eFilters ); | |
1224 | + } | |
1225 | + | |
1226 | + | |
1227 | + // 改めてフィルタ名とピンIDからこれらのインターフェースを取得し、戻り値として返す。 | |
1228 | + | |
1229 | + videoRenderer = null; | |
1230 | + inputPin = null; | |
1231 | + | |
1232 | + if( !string.IsNullOrEmpty( strフィルタ名 ) ) | |
1233 | + { | |
1234 | + hr = graph.FindFilterByName( strフィルタ名, out videoRenderer ); | |
1235 | + DsError.ThrowExceptionForHR( hr ); | |
1236 | + | |
1237 | + hr = videoRenderer.FindPin( strピンID, out inputPin ); | |
1238 | + DsError.ThrowExceptionForHR( hr ); | |
1239 | + } | |
1240 | + } | |
1241 | + | |
983 | 1242 | private static void SearchMMRenderers( IFilterGraph graph, out IBaseFilter videoRenderer, out IPin inputVPin, out IBaseFilter audioRenderer, out IPin inputAPin ) |
984 | 1243 | { |
985 | 1244 | int hr = 0; |