Beispiel #1
0
 private void DisposePageHavingResources()
 {
     try
     {
         Console.WriteLine("DisposePageHavingResources called!");
         if (player != null)
         {
             // サウンド回りの終了処理はこの呼び出しで全て行われる
             player.togglePlayingTCP();
             player = null;
         }
         if (socket != null)
         {
             // input server および image server との通信に利用しているソケットの終了処理
             Device.BeginInvokeOnMainThread(() =>
             {
                 if (socket != null)
                 {
                     socket.Dispose();
                 }
                 socket = null;
             });
         }
         if (vdecoder != null)
         {
             vdecoder.Close();
             vdecoder = null;
         }
     }catch (Exception e) {
         Console.WriteLine(e.ToString());
     }
 }
Beispiel #2
0
        private void Socket_EndDataRecievedCallback()
        {
            //Utils.startTimeMeasure("Image_Update");
            //var tcs = new TaskCompletionSource<bool>();
            Device.BeginInvokeOnMainThread(() =>
            {
                lock (this)
                {
                    Console.WriteLine("elapsed for image data transfer communication: " + Utils.stopMeasureAndGetElapsedMilliSeconds("Image_Transfer_Communication").ToString() + " msec");
                    try
                    {
                        if (GlobalConfiguration.isStreamRawH264Data)
                        {
                            byte[] encoded_buf = compressedStream.ToArray();
                            Console.Write("pass encoded data to decoder length = " + encoded_buf.Length.ToString());


                            if (decoCallback == null)
                            {
                                decoCallback = new DecoderCallback(encodedFrameDataQ);
                                decoCallback.encodedDataGenerated += H264DecodedDataHandler;
                            }

                            decoCallback.addEncodedFrameData(encoded_buf, encoded_buf.Length);

                            if (vdecoder == null)
                            {
                                vdecoder = new VideoDecoderManager();
                                vdecoder.setup(decoCallback, (int)metaData.width, (int)metaData.height);
                            }

                            return;
                        }
                        else if (GlobalConfiguration.isConvJpeg)
                        {
                            Utils.startTimeMeasure("Bitmap_decompress");

                            if (curUpdateTargetComoonentOrBuf == BITMAP_DISPLAY_COMPONENT_TAG.COMPONENT_1)
                            {
                                skiaBufStreams[0].Write(compressedStream.ToArray(), 0, metaData.dataSize);
                            }
                            else
                            {
                                skiaBufStreams[1].Write(compressedStream.ToArray(), 0, metaData.dataSize);
                            }

                            Console.WriteLine("elapsed for jpeg decompress: " + Utils.stopMeasureAndGetElapsedMilliSeconds("Bitmap_decompress").ToString() + " msec");
                        }
                        else if (metaData.compressed)
                        {
                            try
                            {
                                Utils.startTimeMeasure("Bitmap_decompress");
                                compressedStream.Position = 0;
                                using (var gzip = new GZipStream(compressedStream, CompressionMode.Decompress, true))
                                {
                                    var tmpDecompedStream = new MemoryStream();
                                    gzip.CopyTo(tmpDecompedStream);
                                    if (curUpdateTargetComoonentOrBuf == BITMAP_DISPLAY_COMPONENT_TAG.COMPONENT_1)
                                    {
                                        skiaBufStreams[0].Write(tmpDecompedStream.ToArray(), 0, metaData.imageDataSize);
                                    }
                                    else
                                    {
                                        skiaBufStreams[1].Write(tmpDecompedStream.ToArray(), 0, metaData.imageDataSize);
                                    }

                                    Console.WriteLine("elapsed for bitmap decompress: " + Utils.stopMeasureAndGetElapsedMilliSeconds("Bitmap_decompress").ToString() + " msec");
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        }

                        // このメソッドの中でImageコンポーネントへの更新通知も行う
                        dataUpdateTargetImageComponentToggle();

                        Console.WriteLine("new capture image received and update bitmap display!");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                        //tcs.SetException(ex);
                    }

                    if (isBitDisplayComponetsAdded)
                    {
                        totalDisplayedFrames += 1;
                    }
                }
            });
            //var task = tcs.Task;
            //try
            //{
            //    task.Wait();
            //}
            //catch { }
            Console.WriteLine("image update Invoked at EndDataRecievedCallback!");
        }