diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-11-02 23:58:34 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-11-02 23:58:34 +0000 |
commit | 20bf3c992909e83e5af53cf00d87b7cbaef0d1a6 (patch) | |
tree | 0120d448ed644678411423a38e02a42fa2b017ae /mediaplugin/src | |
parent | 5000060b04bed23cbbd88ba43ed546220c4b7c69 (diff) | |
download | usdx-20bf3c992909e83e5af53cf00d87b7cbaef0d1a6.tar.gz usdx-20bf3c992909e83e5af53cf00d87b7cbaef0d1a6.tar.xz usdx-20bf3c992909e83e5af53cf00d87b7cbaef0d1a6.zip |
- Support for media interface priorities
- all media interfaces classes have to explicitly implement IMediaInterface, otherwise access to the priority and name will fail
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2707 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'mediaplugin/src')
-rw-r--r-- | mediaplugin/src/base/UMusic.pas | 66 | ||||
-rw-r--r-- | mediaplugin/src/base/URecord.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UAudioConverterPlugin.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UAudioConverter_SDL.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UAudioConverter_SRC.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UAudioDecoderPlugin.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UAudioDecoder_Bass.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UAudioPlaybackBase.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UMedia_dummy.pas | 46 | ||||
-rw-r--r-- | mediaplugin/src/media/UVideo.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UVideoDecoderPlugin.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UVisualizer.pas | 4 | ||||
-rw-r--r-- | mediaplugin/src/switches.inc | 3 |
13 files changed, 102 insertions, 35 deletions
diff --git a/mediaplugin/src/base/UMusic.pas b/mediaplugin/src/base/UMusic.pas index e93a1037..1f7c8e8f 100644 --- a/mediaplugin/src/base/UMusic.pas +++ b/mediaplugin/src/base/UMusic.pas @@ -738,7 +738,35 @@ begin Result := DefaultAudioConverter; end; -procedure FilterInterfaceList(const IID: TGUID; InList, OutList: TInterfaceList); +{** + * Sort media interfaces in the order of their priority. + * The highest priority interface will be the first in list. + *} +procedure SortMediaIFacesByPrio(List: TInterfaceList); +var + I, N: integer; + Sorted: boolean; + IFace1, IFace2: IMediaInterface; +begin + // this is not time critical, use a simple Bubblesort + N := List.Count - 1; + repeat + Sorted := true; + for I := 1 to N do + begin + IFace1 := (List[I-1] as IMediaInterface); + IFace2 := (List[I] as IMediaInterface); + if (IFace1.GetPriority < IFace2.GetPriority) then + begin + List.Exchange(I-1, I); + Sorted := false; + end; + end; + Dec(N); + until Sorted; +end; + +procedure FilterMediaIFaceList(const IID: TGUID; InList, OutList: TInterfaceList); var i: integer; obj: IInterface; @@ -756,6 +784,7 @@ begin OutList.Add(obj); end; end; + SortMediaIFacesByPrio(OutList); end; procedure InitializeSound; @@ -771,7 +800,7 @@ begin InterfaceList := TInterfaceList.Create(); // initialize all audio-decoders first - FilterInterfaceList(IAudioDecoder, MediaManager, InterfaceList); + FilterMediaIFaceList(IAudioDecoder, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do begin CurrentAudioDecoder := InterfaceList[i] as IAudioDecoder; @@ -784,11 +813,11 @@ begin // create and setup decoder-list (see AudioDecoders()) AudioDecoderList := TInterfaceList.Create; - FilterInterfaceList(IAudioDecoder, MediaManager, AudioDecoders); + FilterMediaIFaceList(IAudioDecoder, MediaManager, AudioDecoders); // find and initialize playback interface DefaultAudioPlayback := nil; - FilterInterfaceList(IAudioPlayback, MediaManager, InterfaceList); + FilterMediaIFaceList(IAudioPlayback, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do begin CurrentAudioPlayback := InterfaceList[i] as IAudioPlayback; @@ -803,7 +832,7 @@ begin // find and initialize converter interface DefaultAudioConverter := nil; - FilterInterfaceList(IAudioConverter, MediaManager, InterfaceList); + FilterMediaIFaceList(IAudioConverter, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do begin CurrentAudioConverter := InterfaceList[i] as IAudioConverter; @@ -818,7 +847,7 @@ begin // find and initialize input interface DefaultAudioInput := nil; - FilterInterfaceList(IAudioInput, MediaManager, InterfaceList); + FilterMediaIFaceList(IAudioInput, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do begin CurrentAudioInput := InterfaceList[i] as IAudioInput; @@ -852,14 +881,17 @@ begin // initialize and set video-playback singleton DefaultVideoPlayback := nil; - FilterInterfaceList(IVideoPlayback, MediaManager, InterfaceList); + FilterMediaIFaceList(IVideoPlayback, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do begin VideoInterface := InterfaceList[i] as IVideoPlayback; + // ignore visualizations + if (Supports(VideoInterface, IVideoVisualization)) then + Continue; if (VideoInterface.Init()) then begin DefaultVideoPlayback := VideoInterface; - break; + Break; end; Log.LogError('Initialize failed, Removing - '+ VideoInterface.GetName); MediaManager.Remove(VideoInterface); @@ -867,7 +899,7 @@ begin // initialize and set video-decoder singleton DefaultVideoDecoder := nil; - FilterInterfaceList(IVideoDecoder, MediaManager, InterfaceList); + FilterMediaIFaceList(IVideoDecoder, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do begin VideoDecoderInterface := InterfaceList[i] as IVideoDecoder; @@ -882,7 +914,7 @@ begin // initialize and set visualization singleton DefaultVisualization := nil; - FilterInterfaceList(IVideoVisualization, MediaManager, InterfaceList); + FilterMediaIFaceList(IVideoVisualization, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do begin VisualInterface := InterfaceList[i] as IVideoVisualization; @@ -923,37 +955,37 @@ begin InterfaceList := TInterfaceList.Create(); // finalize audio playback interfaces (should be done before the decoders) - FilterInterfaceList(IAudioPlayback, MediaManager, InterfaceList); + FilterMediaIFaceList(IAudioPlayback, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do (InterfaceList[i] as IAudioPlayback).FinalizePlayback(); // finalize audio input interfaces - FilterInterfaceList(IAudioInput, MediaManager, InterfaceList); + FilterMediaIFaceList(IAudioInput, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do (InterfaceList[i] as IAudioInput).FinalizeRecord(); // finalize audio decoder interfaces - FilterInterfaceList(IAudioDecoder, MediaManager, InterfaceList); + FilterMediaIFaceList(IAudioDecoder, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do (InterfaceList[i] as IAudioDecoder).FinalizeDecoder(); // finalize audio converter interfaces - FilterInterfaceList(IAudioConverter, MediaManager, InterfaceList); + FilterMediaIFaceList(IAudioConverter, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do (InterfaceList[i] as IAudioConverter).Finalize(); // finalize video interfaces - FilterInterfaceList(IVideoPlayback, MediaManager, InterfaceList); + FilterMediaIFaceList(IVideoPlayback, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do (InterfaceList[i] as IVideoPlayback).Finalize(); // finalize video decoder interfaces - FilterInterfaceList(IVideoDecoder, MediaManager, InterfaceList); + FilterMediaIFaceList(IVideoDecoder, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do (InterfaceList[i] as IVideoDecoder).FinalizeDecoder(); // finalize visualization interfaces - FilterInterfaceList(IVideoVisualization, MediaManager, InterfaceList); + FilterMediaIFaceList(IVideoVisualization, MediaManager, InterfaceList); for i := 0 to InterfaceList.Count-1 do (InterfaceList[i] as IVideoVisualization).Finalize(); diff --git a/mediaplugin/src/base/URecord.pas b/mediaplugin/src/base/URecord.pas index de567aba..d2cfccab 100644 --- a/mediaplugin/src/base/URecord.pas +++ b/mediaplugin/src/base/URecord.pas @@ -169,7 +169,7 @@ type InputDevice: TAudioInputDevice); end; - TAudioInputBase = class( TInterfacedObject, IAudioInput ) + TAudioInputBase = class(TInterfacedObject, IMediaInterface, IAudioInput) private Started: boolean; protected diff --git a/mediaplugin/src/media/UAudioConverterPlugin.pas b/mediaplugin/src/media/UAudioConverterPlugin.pas index 389681ad..5e69e8ca 100644 --- a/mediaplugin/src/media/UAudioConverterPlugin.pas +++ b/mediaplugin/src/media/UAudioConverterPlugin.pas @@ -41,7 +41,7 @@ uses SysUtils; type - TAudioConverterPlugin = class(TInterfacedObject, IAudioConverter) + TAudioConverterPlugin = class(TInterfacedObject, IMediaInterface, IAudioConverter) private fPluginInfo: PMediaPluginInfo; public diff --git a/mediaplugin/src/media/UAudioConverter_SDL.pas b/mediaplugin/src/media/UAudioConverter_SDL.pas index faed8abb..89163fcc 100644 --- a/mediaplugin/src/media/UAudioConverter_SDL.pas +++ b/mediaplugin/src/media/UAudioConverter_SDL.pas @@ -43,7 +43,7 @@ uses Math; type - TAudioConverter_SDL = class(TInterfacedObject, IAudioConverter) + TAudioConverter_SDL = class(TInterfacedObject, IMediaInterface, IAudioConverter) public function GetName(): string; function GetPriority(): integer; diff --git a/mediaplugin/src/media/UAudioConverter_SRC.pas b/mediaplugin/src/media/UAudioConverter_SRC.pas index c4bf4358..964d1035 100644 --- a/mediaplugin/src/media/UAudioConverter_SRC.pas +++ b/mediaplugin/src/media/UAudioConverter_SRC.pas @@ -42,7 +42,7 @@ uses Math; type - TAudioConverter_SRC = class(TInterfacedObject, IAudioConverter) + TAudioConverter_SRC = class(TInterfacedObject, IMediaInterface, IAudioConverter) public function GetName(): string; function GetPriority(): integer; diff --git a/mediaplugin/src/media/UAudioDecoderPlugin.pas b/mediaplugin/src/media/UAudioDecoderPlugin.pas index e518277c..0d23a368 100644 --- a/mediaplugin/src/media/UAudioDecoderPlugin.pas +++ b/mediaplugin/src/media/UAudioDecoderPlugin.pas @@ -50,7 +50,7 @@ uses UPath; type - TAudioDecoderPlugin = class(TInterfacedObject, IAudioDecoder) + TAudioDecoderPlugin = class(TInterfacedObject, IMediaInterface, IAudioDecoder) private fPluginInfo: PMediaPluginInfo; public diff --git a/mediaplugin/src/media/UAudioDecoder_Bass.pas b/mediaplugin/src/media/UAudioDecoder_Bass.pas index e08b91ff..5ef4138b 100644 --- a/mediaplugin/src/media/UAudioDecoder_Bass.pas +++ b/mediaplugin/src/media/UAudioDecoder_Bass.pas @@ -70,7 +70,7 @@ type end; type - TAudioDecoder_Bass = class( TInterfacedObject, IAudioDecoder ) + TAudioDecoder_Bass = class(TInterfacedObject, IMediaInterface, IAudioDecoder) public function GetName: string; function GetPriority: integer; diff --git a/mediaplugin/src/media/UAudioPlaybackBase.pas b/mediaplugin/src/media/UAudioPlaybackBase.pas index 65528430..293dd92a 100644 --- a/mediaplugin/src/media/UAudioPlaybackBase.pas +++ b/mediaplugin/src/media/UAudioPlaybackBase.pas @@ -39,7 +39,7 @@ uses UPath; type - TAudioPlaybackBase = class(TInterfacedObject, IAudioPlayback) + TAudioPlaybackBase = class(TInterfacedObject, IMediaInterface, IAudioPlayback) protected OutputDeviceList: TAudioOutputDeviceList; MusicStream: TAudioPlaybackStream; diff --git a/mediaplugin/src/media/UMedia_dummy.pas b/mediaplugin/src/media/UMedia_dummy.pas index 1ada6603..d5e99aa3 100644 --- a/mediaplugin/src/media/UMedia_dummy.pas +++ b/mediaplugin/src/media/UMedia_dummy.pas @@ -43,7 +43,7 @@ uses UPath; type - TAudio_Dummy = class( TInterfacedObject, IAudioPlayback, IAudioInput ) + TAudio_Dummy = class( TInterfacedObject, IMediaInterface, IAudioPlayback, IAudioInput ) private DummyOutputDeviceList: TAudioOutputDeviceList; public @@ -99,7 +99,7 @@ type procedure CloseVoiceStream(var VoiceStream: TAudioVoiceStream); end; - TVideo_Dummy = class( TInterfacedObject, IVideo ) + TVideo_Dummy = class(TInterfacedObject, IVideo) public procedure Close; @@ -154,7 +154,8 @@ type property Position: real read GetPosition write SetPosition; end; - TVideoPlayback_Dummy = class( TInterfacedObject, IVideoPlayback, IVideoVisualization ) + TVideoPlayback_Dummy = class(TInterfacedObject, IMediaInterface, + IVideoPlayback, IVideoVisualization) public constructor Create(); function GetName: string; @@ -166,6 +167,16 @@ type function Open(const FileName: IPath): IVideo; end; + TVideoDecoder_Dummy = class(TInterfacedObject, IMediaInterface, IVideoDecoder) + public + function GetName: string; + function GetPriority: integer; + + function InitializeDecoder(): boolean; + function FinalizeDecoder(): boolean; + function Open(const FileName: IPath): TVideoDecodeStream; + end; + function TAudio_Dummy.GetName: string; begin Result := 'AudioDummy'; @@ -473,7 +484,7 @@ end; function TVideoPlayback_Dummy.GetName: string; begin - Result := 'VideoDummy'; + Result := 'VideoPlaybackDummy'; end; function TVideoPlayback_Dummy.GetPriority: integer; @@ -496,9 +507,36 @@ begin Result := TVideo_Dummy.Create; end; +{ TVideoDecoder_Dummy } + +function TVideoDecoder_Dummy.GetName: string; +begin + Result := 'VideoDecoderDummy'; +end; + +function TVideoDecoder_Dummy.GetPriority: integer; +begin + Result := -100; +end; + +function TVideoDecoder_Dummy.InitializeDecoder(): boolean; +begin + Result := true; +end; + +function TVideoDecoder_Dummy.FinalizeDecoder(): boolean; +begin + Result := true; +end; + +function TVideoDecoder_Dummy.Open(const FileName: IPath): TVideoDecodeStream; +begin + Result := nil; +end; initialization MediaManager.Add(TAudio_Dummy.Create); MediaManager.Add(TVideoPlayback_Dummy.Create); + MediaManager.Add(TVideoDecoder_Dummy.Create); end. diff --git a/mediaplugin/src/media/UVideo.pas b/mediaplugin/src/media/UVideo.pas index d7fab209..776d9f33 100644 --- a/mediaplugin/src/media/UVideo.pas +++ b/mediaplugin/src/media/UVideo.pas @@ -167,7 +167,7 @@ type procedure DrawReflection(); end; - TVideoPlayback_FFmpeg = class( TInterfacedObject, IVideoPlayback ) + TVideoPlayback_FFmpeg = class(TInterfacedObject, IMediaInterface, IVideoPlayback) public function GetName: String; function GetPriority: integer; diff --git a/mediaplugin/src/media/UVideoDecoderPlugin.pas b/mediaplugin/src/media/UVideoDecoderPlugin.pas index d513a0b3..1655f325 100644 --- a/mediaplugin/src/media/UVideoDecoderPlugin.pas +++ b/mediaplugin/src/media/UVideoDecoderPlugin.pas @@ -39,7 +39,7 @@ uses UPath; type - TVideoDecoderPlugin = class( TInterfacedObject, IVideoDecoder ) + TVideoDecoderPlugin = class(TInterfacedObject, IMediaInterface, IVideoDecoder) private fPluginInfo: PMediaPluginInfo; public diff --git a/mediaplugin/src/media/UVisualizer.pas b/mediaplugin/src/media/UVisualizer.pas index d7fc460c..9497aa55 100644 --- a/mediaplugin/src/media/UVisualizer.pas +++ b/mediaplugin/src/media/UVisualizer.pas @@ -103,7 +103,7 @@ type TGLMatrixStack = array of TGLMatrix; type - TVideo_ProjectM = class( TInterfacedObject, IVideo ) + TVideo_ProjectM = class(TInterfacedObject, IVideo) private fPm: TProjectM; fProjectMPath : string; @@ -177,7 +177,7 @@ type procedure DrawReflection(); end; - TVideoPlayback_ProjectM = class( TInterfacedObject, IVideoVisualization ) + TVideoPlayback_ProjectM = class( TInterfacedObject, IMediaInterface, IVideoVisualization ) private fInitialized: boolean; diff --git a/mediaplugin/src/switches.inc b/mediaplugin/src/switches.inc index 66ed2320..15e38a4d 100644 --- a/mediaplugin/src/switches.inc +++ b/mediaplugin/src/switches.inc @@ -93,9 +93,6 @@ {$ENDIF} {$IFEND} -// ffmpeg config (TODO: remove when dynamically loaded) -{$DEFINE UseFFmpegResample} - {$IFDEF HaveLibsamplerate} {$DEFINE UseSRCResample} {$ENDIF} |