Example #1
0
        public static ITalkTarget GetTalkTarget(objectsCamera cam, IAudioSource source)
        {
            ITalkTarget talkTarget;

            switch (cam.settings.audiomodel)
            {
                default://local playback
                    talkTarget = new TalkLocal(source);
                    break;
                case "Foscam":
                    talkTarget = new TalkFoscam(cam.settings.audioip, cam.settings.audioport,
                        cam.settings.audiousername, cam.settings.audiopassword, source);
                    break;
                case "iSpyServer":
                    talkTarget = new TalkiSpyServer(cam.settings.audioip, cam.settings.audioport,
                        source);
                    break;
                case "NetworkKinect":
                    talkTarget = new TalkNetworkKinect(cam.settings.audioip, cam.settings.audioport,
                        source);
                    break;
                case "Axis":
                    talkTarget = new TalkAxis(cam.settings.audioip, cam.settings.audioport,
                        cam.settings.audiousername, cam.settings.audiopassword, source);
                    break;
                case "IP Webcam (Android)":
                    talkTarget = new TalkIPWebcamAndroid(new Uri(cam.settings.videosourcestring), source);
                    break;
            }
            return talkTarget;
        }
Example #2
0
        public static ITalkTarget GetTalkTarget(objectsCamera cam, IAudioSource source)
        {
            ITalkTarget talkTarget;

            switch (cam.settings.audiomodel)
            {
            default:    //local playback
                talkTarget = new TalkLocal(source);
                break;

            case "Foscam":
                talkTarget = new TalkFoscam(cam.settings.audioip, cam.settings.audioport,
                                            cam.settings.audiousername, cam.settings.audiopassword, source);
                break;

            case "iSpyServer":
                talkTarget = new TalkiSpyServer(cam.settings.audioip, cam.settings.audioport,
                                                source);
                break;

            case "NetworkKinect":
                talkTarget = new TalkNetworkKinect(cam.settings.audioip, cam.settings.audioport,
                                                   source);
                break;

            case "Axis":
                talkTarget = new TalkAxis(cam.settings.audioip, cam.settings.audioport,
                                          cam.settings.audiousername, cam.settings.audiopassword, source);
                break;

            case "IP Webcam (Android)":
                talkTarget = new TalkIPWebcamAndroid(new Uri(cam.settings.videosourcestring), source);
                break;
            }
            return(talkTarget);
        }
Example #3
0
        private void AudioIn(HttpRequest req, int cameraId)
        {
            CameraWindow cw = _parent.GetCameraWindow(cameraId);

            ITalkTarget talkTarget = null;
            var ds = new AudioInStream { RecordingFormat = new WaveFormat(22050, 16, 1) };

            switch (cw.Camobject.settings.audiomodel)
            {
                case "Foscam":
                    ds.Interval = 40;
                    ds.PacketSize = 882; // (40ms packet at 22050 bytes per second)
                    talkTarget = new TalkFoscam(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport,
                                                cw.Camobject.settings.audiousername,
                                                cw.Camobject.settings.audiopassword, ds);
                    break;
                case "NetworkKinect":
                    ds.Interval = 40;
                    ds.PacketSize = 882;
                    talkTarget = new TalkNetworkKinect(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport, ds);
                    break;
                case "iSpyServer":
                    ds.Interval = 40;
                    ds.PacketSize = 882;
                    talkTarget = new TalkiSpyServer(cw.Camobject.settings.audioip,
                                                    cw.Camobject.settings.audioport,
                                                    ds);
                    break;
                case "Axis":
                    talkTarget = new TalkAxis(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport,
                                              cw.Camobject.settings.audiousername,
                                              cw.Camobject.settings.audiopassword, ds);
                    break;
                default:
                    //local playback
                    talkTarget = new TalkLocal(ds);
                    break;
            }

                ds.Start();
                talkTarget.Start();
                ds.PacketSize = 4410;
                var bBuffer = new byte[ds.PacketSize*4];
                //IWavePlayer WaveOut = new DirectSoundOut(100);
                //WaveOut.Init(ds.WaveOutProvider);
                //WaveOut.Play();
                try
                {
                    int j = 0;
                    //DateTime dtStart = Helper.Now;
                    bool pktComplete = false;
                    DateTime dt = Helper.Now;
                    while (req.TcpClient.Client.Connected) // && talkTarget.Connected)
                    {
                        while (!pktComplete && req.TcpClient.Client.Connected)
                        {
                           // DateTime sR = Helper.Now;

                            int i = req.TcpClient.Client.Receive(bBuffer, j, ds.PacketSize, SocketFlags.None);
                            if (i == 0)
                                goto Finish;
                            j += i;
                            while (j >= ds.PacketSize)
                            {
                                var data = new byte[ds.PacketSize];
                                Buffer.BlockCopy(bBuffer, 0, data, 0, ds.PacketSize);
                                ds.AddSamples(data);
                                int ms = Convert.ToInt32((Helper.Now - dt).TotalMilliseconds);
                                if (ms < 40)
                                    Thread.Sleep(40 - ms);
                                dt = Helper.Now;
                                pktComplete = true;
                                Buffer.BlockCopy(bBuffer, ds.PacketSize, bBuffer, 0, j - ds.PacketSize);
                                j = j - ds.PacketSize;

                            }
                        }
                        pktComplete = false;

                        //Thread.Sleep(50);
                    }
                }
                catch
                {

                }
            Finish:
                DisconnectRequest(req);
                ds.Stop();
                talkTarget.Stop();
                talkTarget = null;
                ds = null;
        }
Example #4
0
        private static void SynthToCam(string fileName, CameraWindow cw)
        {
            using (var waveStream = new MemoryStream())
            {

                //write some silence to the stream to allow camera to initialise properly
                var silence = new byte[1 * 22050];
                waveStream.Write(silence, 0, silence.Count());

                //read in and convert the wave stream into our format
                using (var reader = new WaveFileReader(fileName))
                {
                    var newFormat = new WaveFormat(11025, 16, 1);
                    byte[] buff = new byte[22050];

                    using (var conversionStream = new WaveFormatConversionStream(newFormat, reader))
                    {
                        do
                        {
                            int i = conversionStream.Read(buff, 0, 22050);
                            waveStream.Write(buff, 0, i);
                            if (i < 22050)
                                break;
                        } while (true);
                    }
                }

                //write some silence to the stream to allow camera to end properly
                waveStream.Write(silence, 0, silence.Count());

                waveStream.Seek(0, SeekOrigin.Begin);

                ITalkTarget talkTarget;

                var ds = new DirectStream(waveStream) { RecordingFormat = new WaveFormat(11025, 16, 1) };
                switch (cw.Camobject.settings.audiomodel)
                {
                    case "Foscam":
                        ds.Interval = 40;
                        ds.PacketSize = 882; // (40ms packet at 22050 bytes per second)
                        talkTarget = new TalkFoscam(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport,
                                                    cw.Camobject.settings.audiousername,
                                                    cw.Camobject.settings.audiopassword, ds);
                        break;
                    case "NetworkKinect":
                        ds.Interval = 40;
                        ds.PacketSize = 882;
                        talkTarget = new TalkNetworkKinect(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport, ds);
                        break;
                    case "iSpyServer":
                        ds.Interval = 40;
                        ds.PacketSize = 882;
                        talkTarget = new TalkiSpyServer(cw.Camobject.settings.audioip,
                                                        cw.Camobject.settings.audioport,
                                                        ds);
                        break;
                    case "Axis":
                        talkTarget = new TalkAxis(cw.Camobject.settings.audioip, cw.Camobject.settings.audioport,
                                                    cw.Camobject.settings.audiousername,
                                                    cw.Camobject.settings.audiopassword, ds);
                        break;
                    default:
                        //local playback
                        talkTarget = new TalkLocal(ds);

                        break;
                }
                ds.Start();
                talkTarget.Start();
                while (ds.IsRunning)
                {
                    Thread.Sleep(100);
                }
                ds.Stop();
                if (talkTarget != null)
                    talkTarget.Stop();
                talkTarget = null;
                ds = null;

                waveStream.Close();
            }
        }