Exemplo n.º 1
0
 public static bool Equals(VideoFormat c1, VideoFormat c2)
 {
     return c1.nFPS_Denominator == c2.nFPS_Denominator &&
         c1.nFPS_Numerator == c2.nFPS_Numerator &&
         c1.nHeight == c2.nHeight && c1.nWidth == c2.nWidth &&
         c1.picFourCC == c2.picFourCC;
 }
Exemplo n.º 2
0
 /**
  * @brief Initialize a video capture device.
  *
  * To transmit video capture data to a channel call
  * TeamTalk.StartVideoCaptureTransmission()
  *
  * @param szDeviceID The device idenfier @a szDeviceID of #BearWare.VideoCaptureDevice.
  * @param lpVideoFormat The capture format to use,
  * i.e. frame-rate, resolution and picture format.
  * @see TeamTalk.GetVideoCaptureDevices
  * @see TeamTalk.CloseVideoCaptureDevice */
 public bool InitVideoCaptureDevice(string szDeviceID,
     VideoFormat lpVideoFormat)
 {
     return TTDLL.TT_InitVideoCaptureDevice(m_ttInst, szDeviceID, ref lpVideoFormat);
 }
Exemplo n.º 3
0
        public void TestVideoCapture()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_TRANSMIT_VIDEOCAPTURE;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            VideoCaptureDevice[] devs;
            Assert.IsTrue(TeamTalk.GetVideoCaptureDevices(out devs), "get video devs");

            Assert.IsTrue(devs.Length > 0, "Video devs available");

            VideoCaptureDevice dev = devs[0];

            Assert.IsTrue(ttclient.InitVideoCaptureDevice(dev.szDeviceID, dev.videoFormats[0]),
                          "Init video capture device");

            TTMessage msg = new TTMessage();
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_VIDEOCAPTURE, 10000, ref msg),
                          "Get Video capture frame");
            Assert.AreEqual(0, msg.nSource, "Video from self");

            Bitmap bmp = null;
            int counter = 0;

            VideoFrame frm = ttclient.AcquireUserVideoCaptureFrame(0, out bmp);
            Assert.AreNotEqual(0, frm.nHeight, "Valid video frame");
            Assert.AreEqual(dev.videoFormats[0].nWidth, frm.nWidth);
            Assert.AreEqual(dev.videoFormats[0].nHeight, frm.nHeight);

            bmp.Save(MEDIAFOLDER + "\\" + counter++ + ".bmp");
            
            Assert.IsTrue(ttclient.ReleaseUserVideoCaptureFrame(frm), "release video frame");

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            JoinRoot(ttclient);

            Assert.IsTrue(ttclient.CloseVideoCaptureDevice(), "Close vid dev");

            VideoFormat vidfmt = new VideoFormat();
            vidfmt.nFPS_Numerator = 10;
            vidfmt.nFPS_Denominator = 1;
            vidfmt.nWidth = 640;
            vidfmt.nHeight = 480;
            vidfmt.picFourCC = FourCC.FOURCC_RGB32;

            Assert.IsTrue(ttclient.InitVideoCaptureDevice(dev.szDeviceID, vidfmt),
                          "Init video capture device");
            Assert.IsTrue(ttclient.Flags.HasFlag(ClientFlag.CLIENT_VIDEOCAPTURE_READY), "vid cap ready");

            VideoCodec vidcodec = new VideoCodec();
            vidcodec.nCodec = Codec.WEBM_VP8_CODEC;
            vidcodec.webm_vp8.nRcTargetBitrate = 0;

            Assert.IsTrue(ttclient.StartVideoCaptureTransmission(vidcodec), "Start vid tx");

            int cmdid = ttclient.DoSubscribe(ttclient.GetMyUserID(), Subscription.SUBSCRIBE_VIDEOCAPTURE);
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "sub vidcap");

            List<VideoFrame> vidframes = new List<VideoFrame>();

            while (WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_VIDEOCAPTURE, 10000, ref msg))
            {
                if (msg.nSource == ttclient.GetMyUserID())
                {
                    frm = ttclient.AcquireUserVideoCaptureFrame(msg.nSource, out bmp);
                    Assert.IsTrue(frm.nStreamID > 0, "got remote video frame");
                    bmp.Save(MEDIAFOLDER + "\\" + counter++ + ".bmp");

                    vidframes.Add(frm);
                }
                if (vidframes.Count == 10)
                    break;
            }

            foreach (VideoFrame v in vidframes)
                Assert.IsTrue(ttclient.ReleaseUserVideoCaptureFrame(v), "release vid frame");

            Assert.IsTrue(ttclient.Flags.HasFlag(ClientFlag.CLIENT_TX_VIDEOCAPTURE), "Tx'ing vidcap");

            Assert.IsTrue(ttclient.StopVideoCaptureTransmission(), "stop vidcap");

            Assert.IsTrue(ttclient.CloseVideoCaptureDevice(), "close vidcap");
        }