Beispiel #1
0
		/// <summary>Initialize a new VideoStream and add the first frame</summary>
		/// <param name="aviFile">The file that contains the stream</param>
		/// <param name="frameRate">Frames per second</param>
		/// <param name="firstFrame">Image to write into the stream as the first frame</param>
		public VideoStream(int aviFile, Avi.AVICOMPRESSOPTIONS compressOptions, double frameRate, Bitmap firstFrame) {
			CountFrames = 0;
			FirstFrame = 0;
			Initialize(aviFile, true, frameRate, firstFrame);
			CreateStream(compressOptions);
			AddFrame(firstFrame);
		}
        public void AjouterUnAvis(string user_ids, string descriptions, string notes, string nSeos)
        {
            PersonManager mgr       = new PersonManager();
            Avi           nouvelAvi = new Avi();

            nouvelAvi.DateAvis    = DateTime.Now;
            nouvelAvi.Description = descriptions;

            nouvelAvi.UserId = user_ids;
            double dNote = 0;

            if (!double.TryParse(notes, out dNote))
            {
                throw new Exception("Parse Invalid");
            }
            else
            {
                nouvelAvi.Note = dNote;
            }
            using (var context = new AvisEntities())
            {
                var formation = context.Formations.FirstOrDefault(f => f.NomSeo == nSeos);
                nouvelAvi.IdFormation = formation.Id;
                nouvelAvi.Nom         = mgr.GetNameByUserId(user_ids);
                context.Avis.Add(nouvelAvi);
                context.SaveChanges();
            }
        }
Beispiel #3
0
        public IHttpActionResult PutAvi(int id, Avi avi)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != avi.Id)
            {
                return(BadRequest());
            }

            db.Entry(avi).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AviExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #4
0
        public void deleteAvi(Avi avis)
        {
            DMCCTX.ctx.Avis.Attach(avis);
            DMCCTX.ctx.Avis.Remove(avis);

            DMCCTX.ctx.SaveChanges();
        }
Beispiel #5
0
 public ActionResult Edit([Bind(Include = "IdAvis,IdClient,IdProduit,TexteAvis,NoteAvis,DateAvis,IsPublie")] Avi avi)
 {
     if (ModelState.IsValid)
     {
         rep.Modifier(avi);
         return(RedirectToAction("Index"));
     }
     ViewBag.IdClient  = new SelectList(repC.Lister().Select(c => new { c.IdClient, c.NomClient }), "IdClient", "NomClient", avi.IdClient);
     ViewBag.IdProduit = new SelectList(repP.Lister().Select(p => new { p.IdProduit, p.NomProduit }), "IdProduit", "NomProduit", avi.IdProduit);
     return(View(avi));
 }
Beispiel #6
0
        public IHttpActionResult GetAvi(int id)
        {
            Avi avi = db.Avis.Find(id);

            if (avi == null)
            {
                return(NotFound());
            }

            return(Ok(avi));
        }
Beispiel #7
0
        public void updateAvi(Avi avis)
        {
            DMCCTX.ctx.Avis.Attach(avis);
            var entry = DMCCTX.ctx.Entry(avis);

            entry.Property(e => e.Commentaire).IsModified = true;
            entry.Property(e => e.Movy).IsModified        = true;
            entry.Property(e => e.Note).IsModified        = true;
            entry.Property(e => e.User).IsModified        = true;

            DMCCTX.ctx.SaveChanges();
        }
Beispiel #8
0
        public Avi getAvi(int id)
        {
            Avi avis = new Avi();

            var query = DMCCTX.ctx.Avis.Where(a => a.Id.Equals(id)).First();

            DMCCTX.ctx.SaveChanges();

            avis = (Avi)query;

            return(avis);
        }
Beispiel #9
0
        // GET: Avis/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Avi avi = rep.Trouver((int)id);

            if (avi == null)
            {
                return(HttpNotFound());
            }
            return(View(avi));
        }
Beispiel #10
0
        public IHttpActionResult PostAvi(Avi avi)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Avis.Add(avi);
            db.SaveChanges();



            return(CreatedAtRoute("DefaultApi", new { id = avi.Id }, avi));
        }
Beispiel #11
0
        public IHttpActionResult DeleteAvi(int id)
        {
            Avi avi = db.Avis.Find(id);

            if (avi == null)
            {
                return(NotFound());
            }

            db.Avis.Remove(avi);
            db.SaveChanges();

            return(Ok(avi));
        }
Beispiel #12
0
        public void CaptureVideo()
        {
            b = new Bitmap(ScreenWidth, ScreenHeight);
            g = Graphics.FromImage(b);
            g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);


            //auto set options for video recording
            //(description for each option availible at http://msdn.microsoft.com/en-us/library/windows/desktop/dd756832(v=vs.85).aspx)
            Avi.AVICOMPRESSOPTIONS aviOptions = new Avi.AVICOMPRESSOPTIONS();
            aviOptions.fccType = (uint)Avi.streamtypeVIDEO;
            //codec to use MSVC = Microsoft Video 1
            aviOptions.fccHandler = (uint)Avi.mmioStringToFOURCC("MSVC", 0);
            //quality option go from 0-10000
            aviOptions.dwQuality = 5000;

            //change aviOptions to "true" to enable the popup window asking for codec options eg. aviStream = aviManager.AddVideoStream(true, 4, b);
            aviStream = aviManager.AddVideoStream(aviOptions, 4, b);

            Bitmap tempBmp;

            while (!pause)
            {
                tempBmp = new Bitmap(ScreenWidth, ScreenHeight);
                g       = Graphics.FromImage(tempBmp);
                g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);
                g.FillEllipse(fillBrush, currentPoint.X, currentPoint.Y, 10, 10);
                g.FillRectangle(new SolidBrush(Color.Black), ScreenWidth - 100, ScreenHeight - 30, 100, 30);
                g.DrawString(elapsedTime, new Font("Arial", 12), new SolidBrush(Color.White), new PointF(ScreenWidth - 95, ScreenHeight - 25));

                if (tempBmp != null)
                {
                    try
                    {
                        aviStream.AddFrame(tempBmp);
                    }
                    catch
                    {
                        Bitmap bmp2 = tempBmp;
                        tempBmp.Dispose();
                        tempBmp = new Bitmap((Image)bmp2);
                        aviStream.AddFrame(tempBmp);
                    }
                }
                tempBmp.Dispose();
                Thread.Sleep(50);
            }
            aviManager.Close();
        }
Beispiel #13
0
		/// <summary>Returns all data needed to copy the stream</summary>
		/// <remarks>Do not forget to call Marshal.FreeHGlobal and release the raw data pointer</remarks>
		/// <param name="streamInfo">Receives the header information</param>
		/// <param name="format">Receives the format</param>
		/// <param name="streamLength">Receives the length of the stream</param>
		/// <returns>Pointer to the wave data</returns>
		public IntPtr GetStreamData(ref Avi.AVISTREAMINFO streamInfo, ref Avi.PCMWAVEFORMAT format, ref int streamLength) {
			streamInfo = GetStreamInfo();

			format = GetFormat();
			//length in bytes = length in samples * length of a sample
			streamLength = Avi.AVIStreamLength(aviStream.ToInt32()) * streamInfo.dwSampleSize;
			IntPtr waveData = Marshal.AllocHGlobal(streamLength);

			int result = Avi.AVIStreamRead(aviStream, 0, streamLength, waveData, streamLength, 0, 0);
			if (result != 0) {
				throw new Exception("Exception in AVIStreamRead: " + result);
			}

			return waveData;
		}
Beispiel #14
0
        // GET: Avis/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Avi avi = rep.Trouver((int)id);

            if (avi == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdClient  = new SelectList(repC.Lister().Select(c => new { c.IdClient, c.NomClient }), "IdClient", "NomClient", avi.IdClient);
            ViewBag.IdProduit = new SelectList(repP.Lister().Select(p => new { p.IdProduit, p.NomProduit }), "IdProduit", "NomProduit", avi.IdProduit);
            return(View(avi));
        }
Beispiel #15
0
        public ActionResult Create([Bind(Include = "IdAvis,IdClient,IdProduit,TexteAvis,NoteAvis,DateAvis,IsPublie")] Avi avi)
        {
            if (ModelState.IsValid)
            {
                avi.DateAvis  = DateTime.Now;
                avi.IsPublie  = false;
                avi.IdClient  = int.Parse(Session["id"].ToString());
                avi.IdProduit = Convert.ToInt16(Session["idProduit"]);
                rep.Ajouter(avi);
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.IdClient  = new SelectList(repC.Lister().Select(c => new { c.IdClient, c.NomClient }), "IdClient", "NomClient", avi.IdClient);
            ViewBag.IdProduit = new SelectList(repP.Lister().Select(p => new { p.IdProduit, p.NomProduit }), "IdProduit", "NomProduit", avi.IdProduit);
            return(View(avi));
        }
Beispiel #16
0
        private Avi.AVICOMPRESSOPTIONS createCompressedOptions()
        {
            Avi.AVICOMPRESSOPTIONS opts = new Avi.AVICOMPRESSOPTIONS();
            opts.fccType           = (UInt32)Avi.mmioStringToFOURCC("vids", 0);
            opts.fccHandler        = (UInt32)Avi.mmioStringToFOURCC("CVID", 0);
            opts.dwKeyFrameEvery   = 0;
            opts.dwQuality         = 0;                         // 0 .. 10000
            opts.dwFlags           = Avi.AVICOMPRESSF_DATARATE; // AVICOMRPESSF_KEYFRAMES = 4
            opts.dwBytesPerSecond  = 0;
            opts.lpFormat          = new IntPtr(0);
            opts.cbFormat          = 0;
            opts.lpParms           = new IntPtr(0);
            opts.cbParms           = 0;
            opts.dwInterleaveEvery = 0;

            return(opts);
        }
Beispiel #17
0
        /** *********** Methode Add Comment ******** **/
        void AddCommentExe()
        {
            Validator.ValidateAll();
            var validationResult = Validator.GetResult();

            if (validationResult.IsValid)
            {
                /******************* Build Object for commit in Database *******************/
                Avi avis = new Avi();
                avis.Note        = NoteAdd;
                avis.Commentaire = CommentAdd;

                Movy m = new Movy();
                m = DAOF.getMovie(ViewModelLocator.homeViewModel.SelectedMovie);

                avis.Movy      = m;
                avis.Movies_Id = m.Id;

                User u = new User();
                u = DAOF.getUser(ViewModelLocator.mainViewModel.User);

                avis.User    = u;
                avis.User_Id = u.Id;

                /*******************  Insert in Database *******************/
                DAOF.insertAvis(avis);

                /******************* Add Avis in front End *****************/
                AvisList.Add(avis);

                /******************* Remove attribute front End *****************/
                NoteAdd    = 0;
                CommentAdd = "";
                ErrorList  = new List <String>();
            }
            else
            {
                List <string> ErrorListLocal = new List <string>();
                foreach (MvvmValidation.ValidationError validationError in validationResult.ErrorList)
                {
                    ErrorListLocal.Add(validationError.ErrorText);
                }
                ErrorList = ErrorListLocal;
            }
        }
Beispiel #18
0
        public void deleteMovy(Movy movy)
        {
            DAOFacadeSingleton DAOF = new DAOFacadeSingleton();

            if (movy.Avis.Count != 0)
            {
                foreach (Avi a in movy.Avis.ToList())
                {
                    Avi aa = DAOF.getAvi(a.Id);
                    DMCCTX.ctx.Avis.Attach(aa);
                    DMCCTX.ctx.Avis.Remove(aa);
                }
            }

            DMCCTX.ctx.Movies.Attach(movy);
            DMCCTX.ctx.Movies.Remove(movy);

            DMCCTX.ctx.SaveChanges();
        }
 protected void UpdateFunc()
 {
     while (!ExitThread)
     {
         int  wantframe = (int)(Avi.Fps * Time);
         bool newframe  = false;
         while (wantframe > DecodedFrame)
         {
             int l = Avi.ReadFrame(Frame);
             newframe = true;
             XviD.Decode(Frame, l, DecodingSurface);
             DecodedFrame++;
         }
         if (newframe)
         {
             Swap();
         }
         Thread.Sleep(0);
     }
 }
        static void Main(string[] args)
        {
            IVideoMediaVisitor visitor = new ResizeVisitor();
            IMedia             rm      = new Rm();

            rm.Play();
            ((IVideoMedia)rm).Accept(visitor);

            IMedia mpeg = new Mpeg();

            mpeg.Play();
            ((IVideoMedia)mpeg).Accept(visitor);

            IVideoMediaVisitor extendVisitor = new ExtendResizeVisitor();
            IMedia             avi           = new Avi();

            avi.Play();
            ((IVideoMedia)avi).Accept(extendVisitor);

            Console.Read();
        }
Beispiel #21
0
		/// <summary>Add an existing wave audio stream to the file</summary>
		/// <param name="waveData">The new stream's data</param>
		/// <param name="streamInfo">Header info for the new stream</param>
		/// <param name="streamFormat">The new stream' format info</param>
		/// <param name="streamLength">Length of the new stream</param>
		public void AddAudioStream(IntPtr waveData, Avi.AVISTREAMINFO streamInfo, Avi.PCMWAVEFORMAT streamFormat, int streamLength) {
			IntPtr aviStream;
			int result = Avi.AVIFileCreateStream(aviFile, out aviStream, ref streamInfo);
			if (result != 0) {
				throw new Exception("Exception in AVIFileCreateStream: " + result.ToString());
			}

			result = Avi.AVIStreamSetFormat(aviStream, 0, ref streamFormat, Marshal.SizeOf(streamFormat));
			if (result != 0) {
				throw new Exception("Exception in AVIStreamSetFormat: " + result.ToString());
			}

			result = Avi.AVIStreamWrite(aviStream, 0, streamLength, waveData, streamLength, Avi.AVIIF_KEYFRAME, 0, 0);
			if (result != 0) {
				throw new Exception("Exception in AVIStreamWrite: " + result.ToString());
			}

			result = Avi.AVIStreamRelease(aviStream);
			if (result != 0) {
				throw new Exception("Exception in AVIStreamRelease: " + result.ToString());
			}
		}
Beispiel #22
0
		private IntPtr InsertSilence(int countSilentSamples, IntPtr waveData, int lengthWave, ref Avi.AVISTREAMINFO streamInfo) {
			//initialize silence
			int lengthSilence = countSilentSamples * streamInfo.dwSampleSize;
			byte[] silence = new byte[lengthSilence];

			//initialize new sound
			int lengthNewStream = lengthSilence + lengthWave;
			IntPtr newWaveData = Marshal.AllocHGlobal(lengthNewStream);

			//copy silence
			Marshal.Copy(silence, 0, newWaveData, lengthSilence);

			//copy sound
			byte[] sound = new byte[lengthWave];
			Marshal.Copy(waveData, sound, 0, lengthWave);
			IntPtr startOfSound = new IntPtr(newWaveData.ToInt32() + lengthSilence);
			Marshal.Copy(sound, 0, startOfSound, lengthWave);

			Marshal.FreeHGlobal(newWaveData);

			streamInfo.dwLength = lengthNewStream;
			return newWaveData;
		}
Beispiel #23
0
		/// <summary>Add an empty video stream to the file</summary>
		/// <remarks>Compresses the stream without showing the codecs dialog</remarks>
		/// <param name="compressOptions">Compression options</param>
		/// <param name="frameRate">Frames per second</param>
		/// <param name="firstFrame">Image to write into the stream as the first frame</param>
		/// <returns>VideoStream object for the new stream</returns>
		public VideoStream AddVideoStream(Avi.AVICOMPRESSOPTIONS compressOptions, double frameRate, Bitmap firstFrame) {
			VideoStream stream = new VideoStream(aviFile, compressOptions, frameRate, firstFrame);
			streams.Add(stream);
			return stream;
		}
Beispiel #24
0
        public void insertAvi(Avi avis)
        {
            DMCCTX.ctx.Avis.Add(avis);

            DMCCTX.ctx.SaveChanges();
        }
Beispiel #25
0
		/// <summary>Change the AviStreamInfo values and update the frame rate</summary>
		/// <param name="info"></param>
		public void SetInfo(Avi.AVISTREAMINFO info) {
			int result = Avi.EditStreamSetInfo(editableStream, ref info, Marshal.SizeOf(info));
			if (result != 0) {
				throw new Exception("Exception in SetInfo: " + result);
			}
			FrameRate = info.dwRate / info.dwScale;
		}
Beispiel #26
0
		/// <summary>Create a compressed stream from an uncompressed stream</summary>
		private void CreateCompressedStream(Avi.AVICOMPRESSOPTIONS options) {
			int result = Avi.AVIMakeCompressedStream(out compressedStream, aviStream, ref options, 0);
			if (result != 0) {
				throw new Exception("Exception in AVIMakeCompressedStream: " + result);
			}

			compressOptions = options;

			SetFormat(compressedStream);
		}
Beispiel #27
0
		/// <summary>Create a new stream</summary>
		private void CreateStream(Avi.AVICOMPRESSOPTIONS options) {
			CreateStreamWithoutFormat();
			CreateCompressedStream(options);
		}
Beispiel #28
0
		/// <summary>Copy all properties from one VideoStream to another one</summary>
		/// <remarks>Used by EditableVideoStream</remarks>
		/// <param name="frameSize"></param><param name="frameRate"></param>
		/// <param name="width"></param><param name="height"></param>
		/// <param name="countBitsPerPixel"></param>
		/// <param name="countFrames"></param><param name="compressOptions"></param>
		internal VideoStream(int frameSize, double frameRate, int width, int height, Int16 countBitsPerPixel, int countFrames, Avi.AVICOMPRESSOPTIONS compressOptions, bool writeCompressed) {
			FrameSize = frameSize;
			FrameRate = frameRate;
			Width = width;
			Height = height;
			CountBitsPerPixel = countBitsPerPixel;
			CountFrames = countFrames;
			this.compressOptions = compressOptions;
			this.writeCompressed = writeCompressed;
			FirstFrame = 0;
		}