public static void Initialize(string signingIdentity, string instanceId) { if (libraryCallbackDelegate == null) { libraryCallbackDelegate = new NdnRtcLibLogHandler(ndnrtcLogHandler); } bool res; try { res = NdnRtcWrapper.ndnrtc_init("localhost", Application.persistentDataPath, signingIdentity, instanceId, libraryCallbackDelegate); if (res) { LocalStreamParams p = new LocalStreamParams(); p.basePrefix = signingIdentity + "/" + instanceId; p.signingOn = 1; p.dropFrames = 1; p.fecOn = 1; p.frameHeight = 180; p.frameWidth = 320; p.gop = 30; p.startBitrate = 300; p.maxBitrate = 7000; p.ndnDataFreshnessPeriodMs = 2000; p.ndnSegmentSize = 8000; p.typeIsVideo = 1; p.streamName = "back_camera"; p.threadName = "vp9"; videoStream = new LocalVideoStream(p); } } catch (System.Exception e) { Debug.LogError("Error initializing NDN-RTC: " + e.Message); } }
public static void Initialize(string signingIdentity, string instanceId) { if (libraryCallbackDelegate == null) { libraryCallbackDelegate = new NdnRtcLibLogHandler(ndnrtcLogHandler); } bool res; try { string version = Marshal.PtrToStringAnsi(NdnRtcWrapper.ndnrtc_getVersion()); Debug.Log("NDN-RTC version " + version); res = NdnRtcWrapper.ndnrtc_init("localhost", Application.persistentDataPath, signingIdentity, instanceId, libraryCallbackDelegate); if (res) { LocalStreamParams p = new LocalStreamParams(); p.basePrefix = signingIdentity + "/" + instanceId; p.signingOn = 1; p.dropFrames = 1; p.fecOn = 1; p.frameHeight = 180; p.frameWidth = 320; p.gop = 30; p.startBitrate = 300; p.maxBitrate = 7000; p.ndnSegmentSize = 8000; p.typeIsVideo = 1; p.streamName = "back_camera"; p.threadName = "vp9"; p.storagePath = Application.persistentDataPath + "/ndnrtc_storage"; videoStream = new LocalVideoStream(p); runFrameFetching_ = true; queueSem_ = new Semaphore(0, 30); // up to 30 requests. why not?... activeTasks_ = new HashSet <FrameFetchingTask>(); frameFetchingTaskQueue_ = new System.Collections.Generic.Queue <FrameFetchingTask>(); frameFetchingThread_ = new Thread(new ThreadStart(delegate() { while (runFrameFetching_) { Debug.Log("[ff-task-worker]: waiting for new tasks..."); // lock on semaphore / event queueSem_.WaitOne(); // deque FrameFetchingTask ffTask = frameFetchingTaskQueue_.Dequeue(); Debug.Log("[ff-task-worker]: running task for " + ffTask.frameName_); activeTasks_.Add(ffTask); ffTask.run(delegate(FrameFetchingTask fft){ Debug.Log("[ff-task-worker]: task completed: " + fft.frameName_); // cleanup when we are done activeTasks_.Remove(fft); }); } // while })); frameFetchingThread_.Start(); } } catch (System.Exception e) { Debug.LogError("Error initializing NDN-RTC: " + e.Message); } }