.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

video conferencing in asp.net using sql server

Posted By: kavitha     Posted Date: February 22, 2011    Points:2   Category :ASP.Net
hi friends,

how to video conferencing in asp.net using sql server.

please give in detail.

thanks.

Responses
Author: Mahesh             
Posted Date: March 17, 2011     Points: 20   

Hi kavitha, i dont think i can help you completely but this code can be helpful to you to implement video conferincing, See these snippets

//The below code is for sending the mpeg file to server through the network
ms = new MemoryStream();

//Picturebox is getting from image a webcam control in the ratio one jpeg per millisecond
pictureBox1.Image.Save("d:/temppic.jpeg");
//Converting to mpeg format //This user control is conveting jpeg to mpeg.I have taken this from net only
userControl11.LoadPictureBox1("d:/temppic.jpeg"); userControl11.nPictures = 1; userControl11.WriteMPEGSequence();

//Reading Mpeg files to convert into NetworkStream & send to the server
ms = new MemoryStream(File.ReadAllBytes("d:/temppic.mpeg")); byte[] arrImage = ms.GetBuffer(); myclient = new TcpClient(remote_IP, port_number);//Connecting with server //myns=>Network stream; mysw=>BinaryWriter myns = myclient.GetStream(); mysw = new BinaryWriter(myns); mysw.Write(arrImage);

//send the stream to above address
//The below code is for receiving the mpeg file to server through the network

StreamWriter sw = new StreamWriter("D:/temppic.mpeg",true );// Open The Port mytcpl = new TcpListener(int.Parse(text_Camera_rec_port.Text)); mytcpl.Start();// Start Listening on That Port if ((mysocket = mytcpl.AcceptSocket()) != null) { mysocket = mytcpl.AcceptSocket(); // Accept Any Request From Client and Start a Session ns = new NetworkStream(mysocket); // Receives The Binary Data From Port sw = new StreamWriter(ns); //Writing back as file mytcpl.Stop(); // Close TCP Session if (mysocket.Connected == true) // Looping While Connected to Receive Another Message { while (true) { createLog("Start_Receiving_Video_Conference"); Thread.Sleep(1); Start_Receiving_Video_Conference(); // Back to receiving Method

} }
//The below is the code used to convert jpeg to mpeg file. And I have taken this from net
{ int i; int j, k1, k2; long j2; byte tempByte;
int ACSIZE = 1764; byte[] leftoverBits = new byte[10]; byte[] DCbits = new byte[24]; byte[] ACbits = new byte[ACSIZE];
int DCY, DCCR, DCCB, lastDCY, lastDCCR, lastDCCB; int hblock, vblock; byte[,] Y = new byte[16,16]; byte[,] CR = new byte[8,8]; byte[,] CB = new byte[8,8]; byte[,] block = new byte[8,8]; double[,] S = new double[8,8]; int[,] Q = new int[8,8]; int[] ZZ = new int[64]; long imageBytes = 0; long compressedBytes = 0; double compressPercent = 0.0; string mBox = null; long bitRate;
MPEGFunctions MPEG = new MPEGFunctions();
// Retrieve image from pictureBox1 Bitmap img = new Bitmap(pictureBox1.Image); string fileName; imageBytes = img.Height * img.Width * 3;
// Use SaveFile dialog to specify output file name //SaveFileDialog dlg = new SaveFileDialog(); //if (dlg.ShowDialog() != DialogResult.OK) // return; //fileName = dlg.FileName; fileName = "D:/temppic.mpeg";
// Create output file and Memory Stream to write encoded image to
BinaryWriter bw = new BinaryWriter(File.Create(fileName)); MemoryStream ms = new MemoryStream(); FileInfo info = new FileInfo(fileName);
this.Cursor = Cursors.WaitCursor;
// Set up variables to encode image into MPEG frame lastDCY = 128; lastDCCR = lastDCCB = 128; for (i=0; i<10; i++) leftoverBits[i] = 255; for (i=0; i<24; i++) ACbits[i] = 255; for (i=0; i<24; i++) DCbits[i] = 255;
outBytes = 20;
// Write MPEG picture and slice headers to MemoryStream for (i=0; i<10; i++) MPEG.picHeaderBits[i+32] = (byte) ((0 & (int) Math.Pow (2,9-i)) >> (9-i)); MPEG.writeToMS(leftoverBits, MPEG.picHeaderBits, ACbits, ref outBytes); MPEG.writeToMS(leftoverBits, MPEG.sliceHeaderBits, ACbits, ref outBytes);
// Do this for each 16x16 pixel block in the bitmap file for (vblock=0; vblock<img.Height/16; vblock++) for (hblock=0; hblock<img.Width/16; hblock++) { // Write 2 bits for Macroblock header to leftoverbits // leftoverbits = '1', '1'; MPEG.writeMbHeader(leftoverBits);
// Fill the Y[] array with a 16x16 block of RGB values Y = MPEG.getYMatrix(img, vblock, hblock); // Fill the CR and CB arrays with 8x8 blocks by subsampling // the RGB array CR = MPEG.getCRMatrix(img, vblock, hblock); CB = MPEG.getCBMatrix(img, vblock, hblock);
// First calculate DCTs for the 4 Y blocks for (k1=0; k1<2; k1++) for (k2=0; k2<2; k2++) { // Put 8x8 Y blocks into the block[] array and // then calculate the DCT and quantize the result for (i=0; i<8; i++) for (j=0; j<8; j++) block[i,j] = Y[(k1*8 + i),(k2*8 + j)]; S = MPEG.calculateDCT(block); Q = MPEG.Quantize(S);
// Section to differentially Huffman encode DC values // DC is the diffential value for the DC coefficient // lastDC is the running total of the full magnitude // Then send the DC value to DCHuffmanEncode for (i=0; i<24; i++) DCbits[i] = 255; DCY = Q[0,0] - lastDCY; lastDCY += DCY; DCbits = MPEG.DCHuffmanEncode(DCY, MPEG.DCLumCode, MPEG.DCLumSize);
// Section to encode AC Huffman values // Put the AC coefficients into the ACarray[] // in zigzag order, then Huffman encode the // resulting array. for (i=0; i<ACSIZE; i++) ACbits[i] = 255; ZZ = MPEG.Zigzag(Q); ACbits = MPEG.ACHuffmanEncode(ZZ);
// Write the encoded bits to the MemoryStream MPEG.writeToMS(leftoverBits, DCbits, ACbits, ref outBytes); }
// Now calculate the DCT for the CB array and quantize S = MPEG.calculateDCT(CB); Q = MPEG.Quantize(S);
// Encode DC value for (i=0; i<24; i++) DCbits[i] = 255; DCCB = Q[0,0] - lastDCCB; lastDCCB += DCCB; DCbits = MPEG.DCHuffmanEncode(DCCB, MPEG.DCChromCode, MPEG.DCChromSize);
// Encode AC values for (i=0; i<ACSIZE; i++) ACbits[i] = 255; ZZ = MPEG.Zigzag(Q); ACbits = MPEG.ACHuffmanEncode(ZZ);
// Write the encoded bits to the MemoryStream MPEG.writeToMS(leftoverBits, DCbits, ACbits, ref outBytes);
// Now calculate the DCT for the CR array and quantize S = MPEG.calculateDCT(CR); Q = MPEG.Quantize(S);
// Encode DC value for (i=0; i<24; i++) DCbits[i] = 255; DCCR = Q[0,0] - lastDCCR; lastDCCR += DCCR; DCbits = MPEG.DCHuffmanEncode(DCCR, MPEG.DCChromCode, MPEG.DCChromSize);
// Encode AC values for (i=0; i<ACSIZE; i++) ACbits[i] = 255; ZZ = MPEG.Zigzag(Q); ACbits = MPEG.ACHuffmanEncode(ZZ);
// Write the encoded bits to the MemoryStream MPEG.writeToMS(leftoverBits, DCbits, ACbits, ref outBytes); }
// Write EOP bits to the MemoryStream MPEG.writeEOP(leftoverBits, MPEG.EOPBits); outBytes++;
// Put memory stream (which contains the encoded image) into buffer ms = MPEG.getMS(); byte[] buffer = new Byte[ms.Length]; buffer = ms.ToArray();
// Set MPEG Sequence Header bits to correct image size j = 2048; for (i=0; i<12; i++) { MPEG.seqHeaderBits[i+32] = (byte) ((j&img.Width) >> (11-i)); MPEG.seqHeaderBits[i+44] = (byte) ((j&img.Height) >> (11-i)); j >>= 1; }
// Set MPEG Sequence Header bits to bitRate value bitRate = ms.Length * 30 * 8 / 400; j2 = 131072; for (i=0; i<18; i++) { MPEG.seqHeaderBits[i+64] = (byte) ((j2&bitRate) >> (17-i)); j2 >>= 1; }
// Write MPEG Sequence header to file for (i=0; i<12; i++) { tempByte = 0; for (j=0; j<8; j++) tempByte = (byte) (tempByte*2 + MPEG.seqHeaderBits[i*8 + j]); bw.Write(tempByte); }
// Write MPEG GOP header to file for (i=0; i<8; i++) { tempByte = 0; for (j=0; j<8; j++) tempByte = (byte) (tempByte*2 + MPEG.GOPHeaderBits[i*8 + j]); bw.Write(tempByte); }
// Fix the picture header for each MPEG frame and write // the buffer to the file for (i=0; i<nPictures; i++) { for (j=0; j<10; j++) MPEG.picHeaderBits[j+32] = (byte) ((i & (int) Math.Pow (2,9-j))
>> (9-j));
for (j=0; j<4; j++) { tempByte = 0; for (k1=0; k1<8; k1++) tempByte = (byte) (2*tempByte + MPEG.picHeaderBits[j*8 + k1]); buffer[j] = tempByte; } bw.Write(buffer); }
// Write the End Of Sequence header bw.Write((byte) 0x00); bw.Write((byte) 0x00); bw.Write((byte) 0x01); bw.Write((byte) 0xb7); bw.Close();
this.Cursor = Cursors.Arrow;
// Calculate some output statistics outBytes += 4; compressedBytes = outBytes - 20 - 8 - 4; compressPercent = 100.0 - (double) (compressedBytes * 100.0 / imageBytes);
if (nPictures == 1) { mBox = "Original image bytes (24 color bitmap): " + imageBytes.ToString() + "\n"; mBox += "Compressed image bytes: " + compressedBytes.ToString() + "\n"; mBox += "Compression Percentage: " + compressPercent.ToString(); } else { mBox += "Input File Size: " + inputFileLength.ToString() + "\n"; mBox += "Output File Size: " + info.Length.ToString() + "\n"; }
// MessageBox.Show(mBox, "Compression Statistics"); }




Also you can refer following link,
http://www.codeproject.com/KB/IP/Video_Voice_Conferencing.aspx

Thanks & Regards
Mahesh Shahane.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend