static TVideoDecoder CreateDecoder(AndroidJavaObject Extractor, TMediaFormat Format) { TVideoDecoder Decoder = new TVideoDecoder(); Decoder.Texture = CreateDecoderTexture(Format.Width, Format.Height); if (Decoder.Texture == null) { return(null); } try { int TextureId = Decoder.Texture.GetNativeTextureID(); Decoder.SurfaceTexture = new AndroidJavaObject("android.graphics.SurfaceTexture", TextureId); Decoder.Surface = new AndroidJavaObject("android.view.Surface", Decoder.SurfaceTexture); } catch (Exception e) { Log("CreateDecoder::surface:: " + e.Message); return(null); } try { // Log ("Creating codec for " + Format.Mime ); AndroidJavaClass MediaCodecClass = new AndroidJavaClass("android.media.MediaCodec"); Decoder.Decoder = MediaCodecClass.CallStatic <AndroidJavaObject>("createDecoderByType", Format.Mime); // "configure not found" when supplying surface.... Decoder.Decoder.Call("configure", Format.Format, Decoder.Surface, null, 0); Decoder.Decoder.Call("start"); } catch (Exception e) { Log("CreateDecoder::create decoder:: " + e.Message); return(null); } return(Decoder); }
static TVideoDecoder CreateDecoder(AndroidJavaObject Extractor,TMediaFormat Format) { TVideoDecoder Decoder = new TVideoDecoder (); Decoder.Texture = CreateDecoderTexture (Format.Width,Format.Height); if (Decoder.Texture == null) return null; try { int TextureId = Decoder.Texture.GetNativeTextureID(); Decoder.SurfaceTexture = new AndroidJavaObject("android.graphics.SurfaceTexture", TextureId ); Decoder.Surface = new AndroidJavaObject("android.view.Surface", Decoder.SurfaceTexture ); } catch ( Exception e ) { Log ("CreateDecoder::surface:: " + e.Message ); return null; } try { // Log ("Creating codec for " + Format.Mime ); AndroidJavaClass MediaCodecClass = new AndroidJavaClass("android.media.MediaCodec"); Decoder.Decoder = MediaCodecClass.CallStatic<AndroidJavaObject>("createDecoderByType", Format.Mime ); // "configure not found" when supplying surface.... Decoder.Decoder.Call("configure", Format.Format, Decoder.Surface, null, 0); Decoder.Decoder.Call("start"); } catch ( Exception e ) { Log ("CreateDecoder::create decoder:: " + e.Message ); return null; } return Decoder; }
void Init() { int SdkLevel = GetAndroidSDKLevel(); Log("Android SDK " + SdkLevel); mExtractor = LoadExtractor(mFilename); if (mExtractor == null) { return; } TMediaFormat Format = GetFormat(mExtractor); if (Format == null) { return; } Log("Format of track is " + Format.Mime + " " + Format.Width + "x" + Format.Height); //jo.Call<android.media.MediaCodec>("createDecoderByType"); mDecoder = CreateDecoder(mExtractor, Format); mInitialised = true; }
void Init() { int SdkLevel = GetAndroidSDKLevel (); Log ("Android SDK " + SdkLevel); mExtractor = LoadExtractor (mFilename); if ( mExtractor == null ) return; TMediaFormat Format = GetFormat( mExtractor ); if (Format==null) return; Log ("Format of track is " + Format.Mime + " " + Format.Width + "x" + Format.Height); //jo.Call<android.media.MediaCodec>("createDecoderByType"); mDecoder = CreateDecoder (mExtractor, Format); mInitialised = true; }