public bool setup(DecoderCallback callback_obj, int width, int height) //format_hint is aviFileContent { callbackThread = new HandlerThread("H264DecoderHandler"); callbackThread.Start(); handler = new Handler(callbackThread.Looper); mDecoder = MediaCodec.CreateDecoderByType(MIME); mCallbackObj = callback_obj; myCallback = new MyCallback(mDecoder, mCallbackObj); mDecoder.SetCallback(myCallback, handler); //mOutputFormat = mDecoder.GetOutputFormat(); // option B inputFormat = MediaFormat.CreateVideoFormat(MIME, width, height); inputFormat.SetInteger(MediaFormat.KeyMaxInputSize, width * height); inputFormat.SetInteger("durationUs", 63446722); //inputFormat.SetInteger(MediaFormat.KeyColorFormat, (int)MediaCodecCapabilities.Formatyuv420semiplanar); //inputFormat.SetInteger(MediaFormat.KeyIFrameInterval, 60); try { mDecoder.Configure(inputFormat, null, null, 0 /* Decoder */); } catch (Exception ex) { throw ex; } Console.WriteLine("before mDecoder.Start()"); mDecoder.Start(); Console.WriteLine("after mDecoder.Start()"); return(true); }
Future <Codec> _loadAsync(FileImage key, DecoderCallback decode) { #if UNITY_ANDROID && !UNITY_EDITOR var path = Path.Combine(Application.streamingAssetsPath, key.file); #else var path = "file://" + Path.Combine(Application.streamingAssetsPath, key.file); #endif using (var unpackerWWW = UnityWebRequest.Get(path)) { unpackerWWW.SendWebRequest(); while (!unpackerWWW.isDone) { } // This will block in the webplayer. if (unpackerWWW.isNetworkError || unpackerWWW.isHttpError) { throw new Exception($"Failed to get file \"{path}\": {unpackerWWW.error}"); } var data = unpackerWWW.downloadHandler.data; if (data.Length > 0) { return(decode(data)); } throw new Exception("not loaded"); } }
public override ImageStreamCompleter load(FileImage key, DecoderCallback decode) { IEnumerable <DiagnosticsNode> infoCollector() { yield return(new ErrorDescription($"Path: {file}")); } return(new MultiFrameImageStreamCompleter(_loadAsync(key, decode), scale: key.scale, informationCollector: infoCollector)); }
public override ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) { IEnumerable <DiagnosticsNode> infoCollector() { yield return(new DiagnosticsProperty <ImageProvider>("Image provider", this)); yield return(new DiagnosticsProperty <AssetBundleImageKey>("Image key", key)); } return(new MultiFrameImageStreamCompleter( codec: _loadAsync(key, decode), scale: key.scale, informationCollector: infoCollector )); }
Future <Codec> _loadAsync(NetworkImage key, DecoderCallback decode) { var completer = Completer.create(); var isolate = Isolate.current; var panel = UIWidgetsPanelWrapper.current.window; if (panel.isActive()) { panel.startCoroutine(_loadCoroutine(key.url, completer, isolate)); return(completer.future.to <byte[]>().then_ <byte[]>(data => { if (data != null && data.Length > 0) { return decode(data); } throw new Exception("not loaded"); }).to <Codec>()); } return(new Future <Codec>(Future.create(() => FutureOr.value(null)))); }
Future <Codec> _loadAsync(AssetBundleImageKey key, DecoderCallback decode) { Object data; // Hot reload/restart could change whether an asset bundle or key in a // bundle are available, or if it is a network backed bundle. try { data = key.bundle.LoadAsset(key.name); } catch (Exception e) { PaintingBinding.instance.imageCache.evict(key); throw e; } if (data != null && data is Texture2D textureData) { return(decode(textureData.EncodeToPNG())); } else { PaintingBinding.instance.imageCache.evict(key); throw new Exception("Unable to read data"); } }
public override ImageStreamCompleter load(_SizeAwareCacheKey assetBundleImageKey, DecoderCallback decode) { Future <Codec> decodeResize(byte[] bytes, int?cacheWidth = 0, int?cacheHeight = 0) { D.assert( cacheWidth == null && cacheHeight == null, () => "ResizeImage cannot be composed with another ImageProvider that applies cacheWidth or cacheHeight." ); return(decode(bytes, cacheWidth: width, cacheHeight: height)); } return(imageProvider.load(assetBundleImageKey.providerCacheKey, decodeResize)); }
Future <Codec> _loadAsync(MemoryImage key, DecoderCallback decode) { D.assert(key == this); return(decode(bytes)); }
public override ImageStreamCompleter load(MemoryImage key, DecoderCallback decode) { return(new MultiFrameImageStreamCompleter( _loadAsync(key, decode), scale: key.scale)); }
public MyCallback(MediaCodec decoder, DecoderCallback callback_obj) { mCallbackObj = callback_obj; mDecoder = decoder; }
public override ImageStreamCompleter load(T key, DecoderCallback decode) => imageProvider.load(key, decode);