java - Can an Android create SurfaceTexture based on Unity Texture2D? -


my question related to: can android (java not c/c++) plugin alter unity textures?. seems guy bothering same question myself. i've created plugin allows launch stream on android devices, couldn't manage how show video frames on unity interface element (meshrenderer, rawimage).

my unity code:

private void initandroidstreamerobject()     {         androidstreamerobj = new androidjavaobject("makeitbetter.figazzz.com.vitamiousing7.androidstreamer");         int androidint = androidstreamerobj.call<int>("androidint");          debug.log("androidint = " + androidint);     }      public void startstream()     {         //"http://dlqncdn.miaopai.com/stream/mvaux41a4lkuwlobbgugaq__.mp4"; //"rtmp://live.hkstv.hk.lxdns.com/live/hks";         string streamlink = "rtmp://live.hkstv.hk.lxdns.com/live/hks";          system.intptr ptr = _inputtexture.getnativetextureptr();         debug.log("ptr on unity side = " + ptr.toint32());         androidstreamerobj.call("launchstream", streamlink, ptr.toint32());     } 

as can see, initialize android object, native texture pointer texture , send android plugin.

in android plugin next things happen:

public void launchstream(string streamlink, int unitytextureid) {         final int texid = unitytextureid;         final string path = streamlink;          log.i("unity", "hop hop1 = " + path + " textureid = " + unitytextureid);          _curractivity.runonuithread(new runnable() {             @override             public void run() {                  //_streamconnection = new videoview(_curractivity); //(videoview) findviewbyid(r.id.stream_window);                 //_curractivity.addcontentview(_streamconnection, new framelayout.layoutparams(1, 1));                  _streamconnection.setvideopath(path);                 _streamconnection.setmediacontroller(new mediacontroller(_curractivity));                 _streamconnection.requestfocus();                  _streamconnection.setonerrorlistener(new mediaplayer.onerrorlistener() {                     @override                     public boolean onerror(mediaplayer mp, int what, int extra) {                         log.i("unity", "some error, don't know. = " + + " = " + extra);                         return false;                     }                 });                  _streamconnection.setonpreparedlistener(new mediaplayer.onpreparedlistener() {                      @override                     public void onprepared(mediaplayer mediaplayer) {                         mediaplayer.setplaybackspeed(1.0f);                     }                 });                  surfacetexture unitytexture = new surfacetexture(texid);                 if(unitytexture == null)                     log.d("unity", "unitytexture null");                 else                     log.d("unity", "unitytexture ok");                  _cachedsurface = new surface(unitytexture);                 if(_cachedsurface == null)                     log.d("unity", "cachedsurface null");                 else                     log.d("unity", "cachedsurface ok");                  _streamconnection.setsurfacetoplayer(_cachedsurface);                 }         });     } 

you might part of code:

surfacetexture unitytexture = new surfacetexture(texid);                 if(unitytexture == null)                     log.d("unity", "unitytexture null");                 else                     log.d("unity", "unitytexture ok");                  _cachedsurface = new surface(unitytexture);                 if(_cachedsurface == null)                     log.d("unity", "cachedsurface null");                 else                     log.d("unity", "cachedsurface ok");                  _streamconnection.setsurfacetoplayer(_cachedsurface); 

won't work. it's working absolutely fine, tried change surface , ok. it's not if try same unity system. understand can need through low-level native plugin interface. far didn't how can use android plugin. searching tutorials found nothing. appreciate if explain me should do. thank you


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -