├── Pause.png ├── Play.png ├── README.md ├── Setup.png ├── Teardown.png ├── assignment2_medell.sln ├── assignment2_medell.v12.suo └── assignment2_medell ├── App.config ├── Controller.cs ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── RTPModel.cs ├── RTPpacket.cs ├── RTSPModel.cs ├── Resources ├── Pause.png ├── Play.png ├── Setup.png └── Teardown.png ├── View.Designer.cs ├── View.cs ├── View.resx ├── assignment2_medell.csproj ├── bin └── Debug │ ├── assignment2_medell.exe │ ├── assignment2_medell.exe.config │ ├── assignment2_medell.pdb │ ├── assignment2_medell.vshost.exe │ ├── assignment2_medell.vshost.exe.config │ └── assignment2_medell.vshost.exe.manifest └── obj └── Debug ├── DesignTimeResolveAssemblyReferences.cache ├── DesignTimeResolveAssemblyReferencesInput.cache ├── TempPE └── Properties.Resources.Designer.cs.dll ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs ├── assignment2_medell.Properties.Resources.resources ├── assignment2_medell.View.resources ├── assignment2_medell.csproj.FileListAbsolute.txt ├── assignment2_medell.csproj.GenerateResource.Cache ├── assignment2_medell.csprojResolveAssemblyReference.cache ├── assignment2_medell.exe └── assignment2_medell.pdb /Pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/Pause.png -------------------------------------------------------------------------------- /Play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/Play.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VideoClient 2 | Video streaming client developed in C# using RTP and RTSP protocols 3 | 4 | Check out the other side of the project at maxakuru/VideoServer. 5 | 6 | Beware of timeouts and error catching, edge cases are largely unhandled! 7 | -------------------------------------------------------------------------------- /Setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/Setup.png -------------------------------------------------------------------------------- /Teardown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/Teardown.png -------------------------------------------------------------------------------- /assignment2_medell.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "assignment2_medell", "assignment2_medell\assignment2_medell.csproj", "{8ACCC9A5-180E-4CAF-8BE6-8C0BD63638FD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8ACCC9A5-180E-4CAF-8BE6-8C0BD63638FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8ACCC9A5-180E-4CAF-8BE6-8C0BD63638FD}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8ACCC9A5-180E-4CAF-8BE6-8C0BD63638FD}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8ACCC9A5-180E-4CAF-8BE6-8C0BD63638FD}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /assignment2_medell.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell.v12.suo -------------------------------------------------------------------------------- /assignment2_medell/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /assignment2_medell/Controller.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Net.Sockets; 7 | using System.Text; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace assignment2_medell 13 | { 14 | class Controller 15 | { 16 | View _view; 17 | RTSPModel _RTSPModel = null; 18 | Thread serverThread; 19 | RTPModel _RTPmodel = null; 20 | int sessionId = 0; 21 | int cseq; 22 | int RTP_PORT; 23 | Socket _RTSPSocket = null; 24 | bool setSession = true; 25 | System.Timers.Timer timer; 26 | 27 | public Controller() 28 | { 29 | timer = new System.Timers.Timer(); 30 | timer.Interval = 80; 31 | timer.Elapsed += OnElapsedEvent; 32 | //_view = new View(); 33 | } 34 | 35 | private void OnElapsedEvent(object sender, System.Timers.ElapsedEventArgs e) 36 | { 37 | //get the packet that was sent 38 | byte[] rc = _RTPmodel.getStuff(); 39 | int length = _RTPmodel.getReceiveLength(); 40 | 41 | if (_view.printHeader()) 42 | { 43 | byte[] header = new byte[12]; 44 | for(int i=0;i<12;i++) 45 | { 46 | header[i] = rc[i]; 47 | } 48 | var result = string.Concat(header.Select(b => Convert.ToString(b, 2).PadLeft(8, '0').PadRight(9, ' '))); 49 | updateInfoBox(result + "\r\n"); 50 | } 51 | 52 | Bitmap bmp; 53 | using (var ms = new MemoryStream(rc, 12, length-12)) 54 | { 55 | bmp = new Bitmap(ms); 56 | } 57 | _view.putFrame(bmp); 58 | 59 | if(_view.packetReport()) 60 | { 61 | int type = rc[1] & 0x7f; 62 | int i = 2; 63 | int seqNum = (rc[i++] << 8 | rc[i++]); 64 | int timestamp = (rc[i++] << 24) | (rc[i++] << 16) | (rc[i++] << 8) | rc[i++]; 65 | updateInfoBox("Got RTP packet with SeqNum #" + seqNum + " Timestamp " + timestamp + "ms, of type " + type + "\r\n"); 66 | } 67 | } 68 | 69 | internal void button_connect_Click(object sender, EventArgs e) 70 | { 71 | try 72 | { 73 | _view = (View)((Button)sender).FindForm(); 74 | _view.Disable_ConnectButton(); 75 | _RTSPModel = new RTSPModel(Int32.Parse(_view.getPortNumber()), _view.getIpAddress()); 76 | _RTSPSocket = _RTSPModel.AcceptServer(); 77 | 78 | //updateInfoBox("The client " + _RTSPSocket.RemoteEndPoint.ToString() + " has joined" + "\r\n"); 79 | serverThread = new Thread(new ParameterizedThreadStart(Communications)); 80 | serverThread.IsBackground = true; 81 | serverThread.Start(_RTSPSocket); 82 | } 83 | catch { } 84 | } 85 | 86 | private void updateInfoBox(string p) 87 | { 88 | _view.SetInfoBox(p); 89 | } 90 | 91 | private void Communications(object obj) 92 | { 93 | Socket s = (Socket)obj; 94 | byte[] receiveBuffer = new byte[256]; 95 | //_RTPmodel = new RTPModel(_view.getIpAddress()); 96 | 97 | try 98 | { 99 | while (true) 100 | { 101 | int rc = s.Receive(receiveBuffer); 102 | if (rc == 0) 103 | break; 104 | string str = System.Text.Encoding.UTF8.GetString(receiveBuffer, 0, rc); 105 | 106 | _view.SetServerBox(str + "\r\n"); 107 | if (setSession) //set session id once 108 | { 109 | string[] ss = str.Split(new char[] { ' ' }); 110 | sessionId = Convert.ToInt32(ss[ss.Length - 1]); 111 | setSession = false; 112 | } 113 | 114 | } 115 | } 116 | catch(SocketException err) 117 | { 118 | if (s != null) 119 | s.Close(); 120 | } 121 | finally 122 | { 123 | s.Close(); 124 | } 125 | } 126 | 127 | internal void button_setup_click(object sender, EventArgs e) 128 | { 129 | cseq = 1; 130 | updateInfoBox("New RTSP state: READY\r\n"); 131 | _RTPmodel = new RTPModel(_view.getIpAddress()); 132 | RTP_PORT = _RTPmodel.getPort(); 133 | string requestLine = "SETUP rtsp://" + _view.getIpAddress() +":"+ _view.getPortNumber() +"/"+ _view.getVideoName()+ " RTSP/1.0\r\n"; 134 | string cseqLine = "CSeq: " + cseq++ + "\r\n"; 135 | string sessionLine = "Transport: RTP/UDP; client_port= " + RTP_PORT + "\r\n"; 136 | //string sessionLine = "Transport: RTP/UDP; client_port= 25000" + "\r\n"; 137 | string message = requestLine + cseqLine + sessionLine; 138 | byte[] messageBytes = System.Text.Encoding.ASCII.GetBytes(message); 139 | _RTSPSocket.Send(messageBytes); 140 | } 141 | 142 | internal void button_play_click(object sender, EventArgs e) 143 | { 144 | updateInfoBox("New RTSP state: PLAYING\r\n"); 145 | string requestLine = "PLAY rtsp://" + _view.getIpAddress() + ":" + _view.getPortNumber() + "/" + _view.getVideoName() + " RTSP/1.0\r\n"; 146 | string cseqLine = "CSeq: " + cseq++ + "\r\n"; 147 | string sessionLine = "Session: " + sessionId + "\r\n"; 148 | string message = requestLine + cseqLine + sessionLine; 149 | byte[] messageBytes = System.Text.Encoding.ASCII.GetBytes(message); 150 | _RTSPSocket.Send(messageBytes); 151 | 152 | timer.Start(); 153 | } 154 | 155 | internal void button_pause_click(object sender, EventArgs e) 156 | { 157 | updateInfoBox("New RTSP state: READY\r\n"); 158 | string requestLine = "PAUSE rtsp://" + _view.getIpAddress() + ":" + _view.getPortNumber() + "/" + _view.getVideoName() + " RTSP/1.0\r\n"; 159 | string cseqLine = "CSeq: " + cseq++ + "\r\n"; 160 | string sessionLine = "Session: " + sessionId + "\r\n"; 161 | string message = requestLine + cseqLine + sessionLine; 162 | byte[] messageBytes = System.Text.Encoding.ASCII.GetBytes(message); 163 | _RTSPSocket.Send(messageBytes); 164 | timer.Stop(); 165 | } 166 | 167 | internal void button_teardown_click(object sender, EventArgs e) 168 | { 169 | string requestLine = "TEARDOWN rtsp://" + _view.getIpAddress() + ":" + _view.getPortNumber() + "/" + _view.getVideoName() + " RTSP/1.0\r\n"; 170 | string cseqLine = "CSeq: " + cseq++ + "\r\n"; 171 | string sessionLine = "Session: " + sessionId + "\r\n"; 172 | string message = requestLine + cseqLine + sessionLine; 173 | byte[] messageBytes = System.Text.Encoding.ASCII.GetBytes(message); 174 | _RTSPSocket.Send(messageBytes); 175 | _RTPmodel.close(); 176 | _view.wipeFrame(); 177 | timer.Stop(); 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /assignment2_medell/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace assignment2_medell 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new View()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /assignment2_medell/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("assignment2_medell")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("assignment2_medell")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c00109cc-a261-4aa9-b6de-16ea1cb8a6d5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /assignment2_medell/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace assignment2_medell.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("assignment2_medell.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap Pause { 67 | get { 68 | object obj = ResourceManager.GetObject("Pause", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap Play { 77 | get { 78 | object obj = ResourceManager.GetObject("Play", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Drawing.Bitmap. 85 | /// 86 | internal static System.Drawing.Bitmap Setup { 87 | get { 88 | object obj = ResourceManager.GetObject("Setup", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// Looks up a localized resource of type System.Drawing.Bitmap. 95 | /// 96 | internal static System.Drawing.Bitmap Teardown { 97 | get { 98 | object obj = ResourceManager.GetObject("Teardown", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /assignment2_medell/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\Setup.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\Resources\Play.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\Resources\Teardown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | ..\Resources\Pause.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 132 | 133 | -------------------------------------------------------------------------------- /assignment2_medell/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace assignment2_medell.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assignment2_medell/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /assignment2_medell/RTPModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Sockets; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace assignment2_medell 10 | { 11 | class RTPModel 12 | { 13 | UdpClient udpClient; 14 | Socket udpSocket = null; 15 | IPEndPoint EP = null; 16 | int receiveLength; 17 | EndPoint EP2 = null; 18 | int portNo; 19 | 20 | public RTPModel(string ip) 21 | { 22 | try 23 | { 24 | IPAddress destAddress = IPAddress.Parse(ip); 25 | udpClient = new UdpClient(0); 26 | EP = new IPEndPoint(IPAddress.Any, 0); 27 | //udpClient.Connect(destAddress, 0); 28 | portNo = ((IPEndPoint)udpClient.Client.LocalEndPoint).Port; 29 | //EP2 = (EndPoint)EP; 30 | //udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); 31 | //udpSocket.Bind(destEndPoint); 32 | } 33 | catch 34 | { 35 | } 36 | } 37 | 38 | public int getPort() 39 | { 40 | return portNo; 41 | } 42 | 43 | public void close() 44 | { 45 | //udpSocket.Close(); 46 | udpClient.Close(); 47 | } 48 | 49 | public Socket getSocket() 50 | { 51 | return udpSocket; 52 | } 53 | 54 | public IPEndPoint getIPEP() 55 | { 56 | return EP; 57 | } 58 | 59 | internal void sendStuff(byte[] p) 60 | { 61 | udpSocket.SendTo(p, EP); 62 | } 63 | 64 | public int getReceiveLength() 65 | { 66 | return receiveLength; 67 | } 68 | 69 | internal byte[] getStuff() 70 | { 71 | Byte[] toReturn = udpClient.Receive(ref EP); 72 | receiveLength = toReturn.Length; 73 | return toReturn; 74 | /* 75 | byte[] toReturn = new byte[100000]; 76 | receiveLength = udpSocket.ReceiveFrom(toReturn, ref EP2); 77 | return toReturn; 78 | * */ 79 | } 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /assignment2_medell/RTPpacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace assignment2_medell 8 | { 9 | class RTPpacket 10 | { 11 | byte[] header; 12 | byte[] payload; 13 | byte[] packet; 14 | private static int interval = 100; 15 | private byte[] someArray; 16 | private int seqNo; 17 | private int length; 18 | 19 | public RTPpacket(byte[] data, int seqNo) 20 | { 21 | int timestamp = seqNo * interval; 22 | header = createHeader(seqNo, timestamp); 23 | payload = new byte[data.Length]; 24 | payload = data; 25 | packet = new byte[data.Length + 12]; 26 | for (int i = 0; i < 12; i++) 27 | { 28 | packet[i] = header[i]; 29 | } 30 | for (int j = 12; j < data.Length + 12; j++) 31 | { 32 | packet[j] = payload[j - 12]; 33 | } 34 | } 35 | 36 | public RTPpacket(byte[] data, int seqNo, int length) 37 | { 38 | // TODO: Complete member initialization 39 | this.someArray = data; 40 | this.seqNo = seqNo; 41 | this.length = length; 42 | 43 | int timestamp = seqNo * interval; 44 | header = createHeader(seqNo, timestamp); 45 | payload = new byte[length]; 46 | payload = data; 47 | packet = new byte[length + 12]; 48 | for (int i = 0; i < 12; i++) 49 | { 50 | packet[i] = header[i]; 51 | } 52 | for (int j = 12; j < length + 12; j++) 53 | { 54 | packet[j] = payload[j-12]; 55 | } 56 | } 57 | public byte[] createHeader(int sequenceNum, int tStamp) 58 | { 59 | int version = 2; 60 | int padding = 0; 61 | int extension = 0; 62 | int csrcCount = 0; 63 | int marker = 0; 64 | int payloadType = 26; 65 | int sequenceNumber = sequenceNum; 66 | long timestamp = tStamp; 67 | long SSRC = 0; 68 | 69 | byte[] buf = new byte[12]; //allocate this big enough to hold the RTP header + audio data 70 | 71 | //assemble the first bytes according to the RTP spec 72 | 73 | buf[0] = (byte)((version & 0x3) << 6 | (padding & 0x1) << 5 | (extension & 0x0) << 4 | (csrcCount & 0x0)); 74 | 75 | //2.byte 76 | buf[1] = (byte)((marker & 0x1) << 7 | payloadType & 0x7f); 77 | 78 | //squence number, 2 bytes, in big endian format. So the MSB first, then the LSB. 79 | buf[2] = (byte)((sequenceNumber & 0xff00) >> 8); 80 | buf[3] = (byte)(sequenceNumber & 0x00ff); 81 | 82 | //packet timestamp , 4 bytes in big endian format 83 | buf[4] = (byte)((timestamp & 0xff000000) >> 24); 84 | buf[5] = (byte)((timestamp & 0x00ff0000) >> 16); 85 | buf[6] = (byte)((timestamp & 0x0000ff00) >> 8); 86 | buf[7] = (byte)(timestamp & 0x000000ff); 87 | 88 | //our CSRC , 4 bytes in big endian format 89 | buf[8] = (byte)((SSRC & 0xff000000) >> 24); 90 | buf[9] = (byte)((SSRC & 0x00ff0000) >> 16); 91 | buf[10] = (byte)((SSRC & 0x0000ff00) >> 8); 92 | buf[11] = (byte)(SSRC & 0x000000ff); 93 | 94 | 95 | return buf; 96 | } 97 | 98 | public byte[] getBytes() 99 | { 100 | return packet; 101 | } 102 | 103 | internal string getHeader() 104 | { 105 | var result = string.Concat(header.Select(b => Convert.ToString(b, 2).PadLeft(8, '0').PadRight(9,' '))); 106 | return result; 107 | } 108 | } 109 | 110 | /* 111 | class RTPpacket 112 | { 113 | private byte[] header; 114 | private byte[] frame; 115 | private int version, padding, extension, cc, marker, ssrc, seqNo, timeStamp, payloadType, firstPiece; 116 | private static int rate = 80; 117 | private static int HEADERSIZE = 12; 118 | 119 | public RTPpacket() 120 | { 121 | 122 | } 123 | 124 | public RTPpacket(byte[] p, int seqNo) 125 | { 126 | version = 2; 127 | version = version << 6; 128 | padding = 1; 129 | padding = padding << 5; 130 | firstPiece = version | padding; 131 | extension = 0; 132 | cc = 0; 133 | marker = 0; 134 | ssrc = 0; 135 | 136 | //fill changing header fields: 137 | this.seqNo = seqNo; 138 | timeStamp = seqNo*rate; 139 | payloadType = 26; 140 | 141 | frame = makeFrame(p); 142 | } 143 | 144 | private byte[] makeFrame(byte[] basePacket) 145 | { 146 | //make 12 header bytes 147 | header = new byte[HEADERSIZE]; 148 | header[0] = (byte)firstPiece; 149 | header[1] = (byte)payloadType; 150 | header[2] = (byte)seqNo; 151 | header[4] = (byte)timeStamp; 152 | header[5] = 0; 153 | header[6] = 0; 154 | header[7] = 0; 155 | header[8] = 0; 156 | header[9] = 0; 157 | header[10] = 0; 158 | header[11] = 0; 159 | Console.Write("header as string: " + header.ToString()); 160 | 161 | //check length of basePacket 162 | int length = basePacket.Length; 163 | 164 | //create new byte array of size length + 12 bytes 165 | byte[] fullFrame = new byte[length + HEADERSIZE]; 166 | 167 | //add header to first 12 bytes 168 | for(int i=0; i 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.textBox_port = new System.Windows.Forms.TextBox(); 33 | this.label2 = new System.Windows.Forms.Label(); 34 | this.textBox_ip = new System.Windows.Forms.TextBox(); 35 | this.label3 = new System.Windows.Forms.Label(); 36 | this.textBox_videoName = new System.Windows.Forms.TextBox(); 37 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 38 | this.pictureBox_teardown = new System.Windows.Forms.PictureBox(); 39 | this.pictureBox_setup = new System.Windows.Forms.PictureBox(); 40 | this.pictureBox_pause = new System.Windows.Forms.PictureBox(); 41 | this.pictureBox_play = new System.Windows.Forms.PictureBox(); 42 | this.button_teardown = new System.Windows.Forms.Button(); 43 | this.button_pause = new System.Windows.Forms.Button(); 44 | this.button_play = new System.Windows.Forms.Button(); 45 | this.button_setup = new System.Windows.Forms.Button(); 46 | this.pictureBox = new System.Windows.Forms.PictureBox(); 47 | this.textBox_packetReport = new System.Windows.Forms.TextBox(); 48 | this.label4 = new System.Windows.Forms.Label(); 49 | this.textBox_serverResponse = new System.Windows.Forms.TextBox(); 50 | this.button_connect = new System.Windows.Forms.Button(); 51 | this.button_exit = new System.Windows.Forms.Button(); 52 | this.checkBox_packetReport = new System.Windows.Forms.CheckBox(); 53 | this.checkBox_printHeader = new System.Windows.Forms.CheckBox(); 54 | this.groupBox1.SuspendLayout(); 55 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox_teardown)).BeginInit(); 56 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox_setup)).BeginInit(); 57 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox_pause)).BeginInit(); 58 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox_play)).BeginInit(); 59 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); 60 | this.SuspendLayout(); 61 | // 62 | // label1 63 | // 64 | this.label1.AutoSize = true; 65 | this.label1.Location = new System.Drawing.Point(42, 36); 66 | this.label1.Name = "label1"; 67 | this.label1.Size = new System.Drawing.Size(124, 20); 68 | this.label1.TabIndex = 0; 69 | this.label1.Text = "Connect to Port:"; 70 | this.label1.Click += new System.EventHandler(this.label1_Click); 71 | // 72 | // textBox_port 73 | // 74 | this.textBox_port.Location = new System.Drawing.Point(172, 33); 75 | this.textBox_port.MaxLength = 5; 76 | this.textBox_port.Name = "textBox_port"; 77 | this.textBox_port.Size = new System.Drawing.Size(100, 26); 78 | this.textBox_port.TabIndex = 1; 79 | this.textBox_port.Text = "3000"; 80 | // 81 | // label2 82 | // 83 | this.label2.AutoSize = true; 84 | this.label2.Location = new System.Drawing.Point(320, 36); 85 | this.label2.Name = "label2"; 86 | this.label2.Size = new System.Drawing.Size(139, 20); 87 | this.label2.TabIndex = 2; 88 | this.label2.Text = "Server IP address:"; 89 | // 90 | // textBox_ip 91 | // 92 | this.textBox_ip.Location = new System.Drawing.Point(476, 30); 93 | this.textBox_ip.MaxLength = 15; 94 | this.textBox_ip.Name = "textBox_ip"; 95 | this.textBox_ip.Size = new System.Drawing.Size(100, 26); 96 | this.textBox_ip.TabIndex = 3; 97 | this.textBox_ip.Text = "127.0.0.1"; 98 | // 99 | // label3 100 | // 101 | this.label3.AutoSize = true; 102 | this.label3.Location = new System.Drawing.Point(631, 36); 103 | this.label3.Name = "label3"; 104 | this.label3.Size = new System.Drawing.Size(98, 20); 105 | this.label3.TabIndex = 4; 106 | this.label3.Text = "Video name:"; 107 | // 108 | // textBox_videoName 109 | // 110 | this.textBox_videoName.Location = new System.Drawing.Point(736, 32); 111 | this.textBox_videoName.Name = "textBox_videoName"; 112 | this.textBox_videoName.Size = new System.Drawing.Size(100, 26); 113 | this.textBox_videoName.TabIndex = 5; 114 | this.textBox_videoName.Text = "video1.mjpeg"; 115 | // 116 | // groupBox1 117 | // 118 | this.groupBox1.Controls.Add(this.pictureBox_teardown); 119 | this.groupBox1.Controls.Add(this.pictureBox_setup); 120 | this.groupBox1.Controls.Add(this.pictureBox_pause); 121 | this.groupBox1.Controls.Add(this.pictureBox_play); 122 | this.groupBox1.Controls.Add(this.button_teardown); 123 | this.groupBox1.Controls.Add(this.button_pause); 124 | this.groupBox1.Controls.Add(this.button_play); 125 | this.groupBox1.Controls.Add(this.button_setup); 126 | this.groupBox1.Controls.Add(this.pictureBox); 127 | this.groupBox1.Location = new System.Drawing.Point(46, 74); 128 | this.groupBox1.Name = "groupBox1"; 129 | this.groupBox1.Size = new System.Drawing.Size(779, 572); 130 | this.groupBox1.TabIndex = 6; 131 | this.groupBox1.TabStop = false; 132 | // 133 | // pictureBox_teardown 134 | // 135 | this.pictureBox_teardown.Image = global::assignment2_medell.Properties.Resources.Teardown; 136 | this.pictureBox_teardown.Location = new System.Drawing.Point(558, 380); 137 | this.pictureBox_teardown.Name = "pictureBox_teardown"; 138 | this.pictureBox_teardown.Size = new System.Drawing.Size(63, 50); 139 | this.pictureBox_teardown.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 140 | this.pictureBox_teardown.TabIndex = 9; 141 | this.pictureBox_teardown.TabStop = false; 142 | this.pictureBox_teardown.Visible = false; 143 | this.pictureBox_teardown.Click += new System.EventHandler(this.pictureBox_teardown_Click); 144 | // 145 | // pictureBox_setup 146 | // 147 | this.pictureBox_setup.Image = global::assignment2_medell.Properties.Resources.Setup; 148 | this.pictureBox_setup.Location = new System.Drawing.Point(157, 380); 149 | this.pictureBox_setup.Name = "pictureBox_setup"; 150 | this.pictureBox_setup.Size = new System.Drawing.Size(59, 50); 151 | this.pictureBox_setup.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 152 | this.pictureBox_setup.TabIndex = 12; 153 | this.pictureBox_setup.TabStop = false; 154 | this.pictureBox_setup.Visible = false; 155 | this.pictureBox_setup.Click += new System.EventHandler(this.pictureBox_setup_Click); 156 | // 157 | // pictureBox_pause 158 | // 159 | this.pictureBox_pause.BackColor = System.Drawing.Color.Transparent; 160 | this.pictureBox_pause.Image = global::assignment2_medell.Properties.Resources.Pause; 161 | this.pictureBox_pause.Location = new System.Drawing.Point(415, 380); 162 | this.pictureBox_pause.Name = "pictureBox_pause"; 163 | this.pictureBox_pause.Size = new System.Drawing.Size(64, 50); 164 | this.pictureBox_pause.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 165 | this.pictureBox_pause.TabIndex = 10; 166 | this.pictureBox_pause.TabStop = false; 167 | this.pictureBox_pause.Visible = false; 168 | this.pictureBox_pause.Click += new System.EventHandler(this.pictureBox_pause_Click); 169 | // 170 | // pictureBox_play 171 | // 172 | this.pictureBox_play.Image = global::assignment2_medell.Properties.Resources.Play; 173 | this.pictureBox_play.Location = new System.Drawing.Point(288, 380); 174 | this.pictureBox_play.Name = "pictureBox_play"; 175 | this.pictureBox_play.Size = new System.Drawing.Size(61, 50); 176 | this.pictureBox_play.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 177 | this.pictureBox_play.TabIndex = 11; 178 | this.pictureBox_play.TabStop = false; 179 | this.pictureBox_play.Visible = false; 180 | this.pictureBox_play.Click += new System.EventHandler(this.pictureBox_play_Click); 181 | // 182 | // button_teardown 183 | // 184 | this.button_teardown.Enabled = false; 185 | this.button_teardown.Location = new System.Drawing.Point(658, 448); 186 | this.button_teardown.Name = "button_teardown"; 187 | this.button_teardown.Size = new System.Drawing.Size(115, 111); 188 | this.button_teardown.TabIndex = 4; 189 | this.button_teardown.Text = "Teardown"; 190 | this.button_teardown.UseVisualStyleBackColor = true; 191 | this.button_teardown.Click += new System.EventHandler(this.button_teardown_Click); 192 | // 193 | // button_pause 194 | // 195 | this.button_pause.Enabled = false; 196 | this.button_pause.Location = new System.Drawing.Point(442, 448); 197 | this.button_pause.Name = "button_pause"; 198 | this.button_pause.Size = new System.Drawing.Size(114, 112); 199 | this.button_pause.TabIndex = 3; 200 | this.button_pause.Text = "Pause"; 201 | this.button_pause.UseVisualStyleBackColor = true; 202 | this.button_pause.Click += new System.EventHandler(this.button_pause_Click); 203 | // 204 | // button_play 205 | // 206 | this.button_play.Enabled = false; 207 | this.button_play.Location = new System.Drawing.Point(223, 448); 208 | this.button_play.Name = "button_play"; 209 | this.button_play.Size = new System.Drawing.Size(116, 112); 210 | this.button_play.TabIndex = 2; 211 | this.button_play.Text = "Play"; 212 | this.button_play.UseVisualStyleBackColor = true; 213 | this.button_play.Click += new System.EventHandler(this.button_play_Click); 214 | // 215 | // button_setup 216 | // 217 | this.button_setup.Enabled = false; 218 | this.button_setup.Location = new System.Drawing.Point(6, 448); 219 | this.button_setup.Name = "button_setup"; 220 | this.button_setup.Size = new System.Drawing.Size(114, 112); 221 | this.button_setup.TabIndex = 1; 222 | this.button_setup.Text = "Setup"; 223 | this.button_setup.UseVisualStyleBackColor = true; 224 | this.button_setup.Click += new System.EventHandler(this.button_setup_Click); 225 | // 226 | // pictureBox 227 | // 228 | this.pictureBox.Location = new System.Drawing.Point(6, 15); 229 | this.pictureBox.Name = "pictureBox"; 230 | this.pictureBox.Size = new System.Drawing.Size(767, 427); 231 | this.pictureBox.TabIndex = 0; 232 | this.pictureBox.TabStop = false; 233 | this.pictureBox.MouseLeave += new System.EventHandler(this.pictureBox_MouseLeave); 234 | this.pictureBox.MouseHover += new System.EventHandler(this.pictureBox_MouseHover); 235 | // 236 | // textBox_packetReport 237 | // 238 | this.textBox_packetReport.Location = new System.Drawing.Point(52, 676); 239 | this.textBox_packetReport.Multiline = true; 240 | this.textBox_packetReport.Name = "textBox_packetReport"; 241 | this.textBox_packetReport.ReadOnly = true; 242 | this.textBox_packetReport.Size = new System.Drawing.Size(651, 169); 243 | this.textBox_packetReport.TabIndex = 7; 244 | // 245 | // label4 246 | // 247 | this.label4.AutoSize = true; 248 | this.label4.Location = new System.Drawing.Point(48, 881); 249 | this.label4.Name = "label4"; 250 | this.label4.Size = new System.Drawing.Size(144, 20); 251 | this.label4.TabIndex = 8; 252 | this.label4.Text = "Server Responses:"; 253 | // 254 | // textBox_serverResponse 255 | // 256 | this.textBox_serverResponse.Location = new System.Drawing.Point(52, 918); 257 | this.textBox_serverResponse.Multiline = true; 258 | this.textBox_serverResponse.Name = "textBox_serverResponse"; 259 | this.textBox_serverResponse.ReadOnly = true; 260 | this.textBox_serverResponse.Size = new System.Drawing.Size(651, 182); 261 | this.textBox_serverResponse.TabIndex = 9; 262 | // 263 | // button_connect 264 | // 265 | this.button_connect.Location = new System.Drawing.Point(736, 973); 266 | this.button_connect.Name = "button_connect"; 267 | this.button_connect.Size = new System.Drawing.Size(109, 35); 268 | this.button_connect.TabIndex = 10; 269 | this.button_connect.Text = "Connect"; 270 | this.button_connect.UseVisualStyleBackColor = true; 271 | this.button_connect.Click += new System.EventHandler(this.button_connect_Click); 272 | // 273 | // button_exit 274 | // 275 | this.button_exit.Location = new System.Drawing.Point(736, 1037); 276 | this.button_exit.Name = "button_exit"; 277 | this.button_exit.Size = new System.Drawing.Size(109, 29); 278 | this.button_exit.TabIndex = 11; 279 | this.button_exit.Text = "Exit"; 280 | this.button_exit.UseVisualStyleBackColor = true; 281 | this.button_exit.Click += new System.EventHandler(this.button_exit_Click); 282 | // 283 | // checkBox_packetReport 284 | // 285 | this.checkBox_packetReport.AutoSize = true; 286 | this.checkBox_packetReport.Location = new System.Drawing.Point(736, 717); 287 | this.checkBox_packetReport.Name = "checkBox_packetReport"; 288 | this.checkBox_packetReport.Size = new System.Drawing.Size(137, 24); 289 | this.checkBox_packetReport.TabIndex = 12; 290 | this.checkBox_packetReport.Text = "Packet Report"; 291 | this.checkBox_packetReport.UseVisualStyleBackColor = true; 292 | // 293 | // checkBox_printHeader 294 | // 295 | this.checkBox_printHeader.AutoSize = true; 296 | this.checkBox_printHeader.Location = new System.Drawing.Point(736, 765); 297 | this.checkBox_printHeader.Name = "checkBox_printHeader"; 298 | this.checkBox_printHeader.Size = new System.Drawing.Size(124, 24); 299 | this.checkBox_printHeader.TabIndex = 13; 300 | this.checkBox_printHeader.Text = "Print Header"; 301 | this.checkBox_printHeader.UseVisualStyleBackColor = true; 302 | // 303 | // View 304 | // 305 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); 306 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 307 | this.ClientSize = new System.Drawing.Size(873, 1130); 308 | this.Controls.Add(this.checkBox_printHeader); 309 | this.Controls.Add(this.checkBox_packetReport); 310 | this.Controls.Add(this.button_exit); 311 | this.Controls.Add(this.button_connect); 312 | this.Controls.Add(this.textBox_serverResponse); 313 | this.Controls.Add(this.label4); 314 | this.Controls.Add(this.textBox_packetReport); 315 | this.Controls.Add(this.groupBox1); 316 | this.Controls.Add(this.textBox_videoName); 317 | this.Controls.Add(this.label3); 318 | this.Controls.Add(this.textBox_ip); 319 | this.Controls.Add(this.label2); 320 | this.Controls.Add(this.textBox_port); 321 | this.Controls.Add(this.label1); 322 | this.Name = "View"; 323 | this.Text = "Form1"; 324 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.View_MouseMove); 325 | this.groupBox1.ResumeLayout(false); 326 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox_teardown)).EndInit(); 327 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox_setup)).EndInit(); 328 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox_pause)).EndInit(); 329 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox_play)).EndInit(); 330 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); 331 | this.ResumeLayout(false); 332 | this.PerformLayout(); 333 | 334 | } 335 | 336 | #endregion 337 | 338 | private System.Windows.Forms.Label label1; 339 | private System.Windows.Forms.TextBox textBox_port; 340 | private System.Windows.Forms.Label label2; 341 | private System.Windows.Forms.TextBox textBox_ip; 342 | private System.Windows.Forms.Label label3; 343 | private System.Windows.Forms.TextBox textBox_videoName; 344 | private System.Windows.Forms.GroupBox groupBox1; 345 | private System.Windows.Forms.Button button_teardown; 346 | private System.Windows.Forms.Button button_pause; 347 | private System.Windows.Forms.Button button_play; 348 | private System.Windows.Forms.Button button_setup; 349 | private System.Windows.Forms.TextBox textBox_packetReport; 350 | private System.Windows.Forms.Label label4; 351 | private System.Windows.Forms.TextBox textBox_serverResponse; 352 | private System.Windows.Forms.Button button_connect; 353 | private System.Windows.Forms.Button button_exit; 354 | private System.Windows.Forms.CheckBox checkBox_packetReport; 355 | private System.Windows.Forms.CheckBox checkBox_printHeader; 356 | private System.Windows.Forms.PictureBox pictureBox_setup; 357 | private System.Windows.Forms.PictureBox pictureBox_play; 358 | private System.Windows.Forms.PictureBox pictureBox_pause; 359 | private System.Windows.Forms.PictureBox pictureBox_teardown; 360 | private System.Windows.Forms.PictureBox pictureBox; 361 | } 362 | } 363 | 364 | -------------------------------------------------------------------------------- /assignment2_medell/View.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace assignment2_medell 13 | { 14 | public partial class View : Form 15 | { 16 | Controller _controller; 17 | 18 | public View() 19 | { 20 | InitializeComponent(); 21 | _controller = new Controller(); 22 | this.textBox_packetReport.ScrollBars = ScrollBars.Vertical; 23 | this.textBox_packetReport.ReadOnly = true; 24 | this.textBox_serverResponse.ScrollBars = ScrollBars.Vertical; 25 | this.textBox_serverResponse.ReadOnly = true; 26 | } 27 | 28 | private void label1_Click(object sender, EventArgs e) 29 | { 30 | 31 | } 32 | 33 | private void button_connect_Click(object sender, EventArgs e) 34 | { 35 | button_setup.Enabled = true; 36 | _controller.button_connect_Click(sender, e); 37 | } 38 | 39 | internal void Disable_ConnectButton() 40 | { 41 | this.button_connect.Enabled = false; 42 | this.button_setup.Enabled = true; 43 | } 44 | 45 | 46 | private void View_MouseMove(object sender, MouseEventArgs e) 47 | { 48 | //if ((this.pictureBox.Bounds.Contains(e.Location) || this.pictureBox_pause.Bounds.Contains(e.Location)) 49 | //&& !this.pictureBox_pause.Visible) 50 | //this.pictureBox_pause.Show(); 51 | } 52 | 53 | private void pictureBox_MouseLeave(object sender, System.EventArgs e) 54 | { 55 | Point relativept = groupBox1.PointToClient(Cursor.Position); 56 | Rectangle rect = new Rectangle(pictureBox_setup.Bounds.X, 57 | pictureBox_pause.Bounds.Y+5, 58 | pictureBox_teardown.Bounds.X+pictureBox_teardown.Width-pictureBox_setup.Bounds.X, 59 | pictureBox_setup.Bounds.Height); 60 | //this keeps the picture buttons from disappearing when the picturebox loses the mouse hover 61 | if(!rect.Contains(relativept)) 62 | { 63 | this.pictureBox_play.Visible = false; 64 | this.pictureBox_setup.Visible = false; 65 | this.pictureBox_teardown.Visible = false; 66 | this.pictureBox_pause.Visible = false; 67 | } 68 | } 69 | 70 | private void pictureBox_MouseHover(object sender, System.EventArgs e) 71 | { 72 | //on hover over the video, show picture buttons 73 | this.pictureBox_pause.Visible = true; 74 | this.pictureBox_play.Visible = true; 75 | this.pictureBox_setup.Visible = true; 76 | this.pictureBox_teardown.Visible = true; 77 | } 78 | 79 | private void pictureBox_setup_Click(object sender, EventArgs e) 80 | { 81 | if(button_setup.Enabled) 82 | this.button_setup_Click(sender, e); 83 | } 84 | 85 | private void pictureBox_play_Click(object sender, EventArgs e) 86 | { 87 | if (button_play.Enabled) 88 | this.button_play_Click(sender, e); 89 | } 90 | 91 | private void pictureBox_pause_Click(object sender, EventArgs e) 92 | { 93 | if (button_pause.Enabled) 94 | this.button_pause_Click(sender, e); 95 | } 96 | 97 | private void pictureBox_teardown_Click(object sender, EventArgs e) 98 | { 99 | if (button_teardown.Enabled) 100 | this.button_teardown_Click(sender, e); 101 | } 102 | 103 | internal string getPortNumber() 104 | { 105 | return textBox_port.Text; 106 | } 107 | 108 | internal string getIpAddress() 109 | { 110 | return textBox_ip.Text; 111 | } 112 | 113 | private void button_setup_Click(object sender, EventArgs e) 114 | { 115 | button_setup.Enabled = false; 116 | button_play.Enabled = true; 117 | button_teardown.Enabled = true; 118 | textBox_ip.ReadOnly = true; 119 | textBox_port.ReadOnly = true; 120 | textBox_videoName.ReadOnly = true; 121 | _controller.button_setup_click(sender, e); 122 | } 123 | 124 | private void button_play_Click(object sender, EventArgs e) 125 | { 126 | button_play.Enabled = false; 127 | button_pause.Enabled = true; 128 | _controller.button_play_click(sender, e); 129 | } 130 | 131 | private void button_pause_Click(object sender, EventArgs e) 132 | { 133 | button_play.Enabled = true; 134 | button_pause.Enabled = false; 135 | _controller.button_pause_click(sender, e); 136 | } 137 | 138 | private void button_teardown_Click(object sender, EventArgs e) 139 | { 140 | button_play.Enabled = false; 141 | button_setup.Enabled = true; 142 | button_teardown.Enabled = false; 143 | textBox_ip.ReadOnly = false; 144 | textBox_port.ReadOnly = false; 145 | textBox_videoName.ReadOnly = false; 146 | _controller.button_teardown_click(sender, e); 147 | } 148 | 149 | internal string getVideoName() 150 | { 151 | return textBox_videoName.Text; 152 | } 153 | 154 | delegate void SetInfoCallback(string info); 155 | 156 | internal void SetServerBox(string _msg) 157 | { 158 | string text = _msg; 159 | SetInfoCallback d = new SetInfoCallback(add_server_text); 160 | this.Invoke(d, new Object[] { text }); 161 | } 162 | 163 | public void add_server_text(String _msg) 164 | { 165 | this.textBox_serverResponse.Text += _msg; 166 | } 167 | 168 | private void button_exit_Click(object sender, EventArgs e) 169 | { 170 | this.Close(); 171 | } 172 | 173 | internal void putFrame(Bitmap bmp) 174 | { 175 | //Bitmap i = new Bitmap(bmp, pictureBox.Size); 176 | pictureBox.Image = (Image)new Bitmap(bmp, pictureBox.Size); 177 | } 178 | 179 | internal void wipeFrame() 180 | { 181 | pictureBox.Image = null; 182 | } 183 | 184 | internal bool printHeader() 185 | { 186 | return checkBox_printHeader.Checked; 187 | } 188 | 189 | internal bool packetReport() 190 | { 191 | return checkBox_packetReport.Checked; 192 | } 193 | 194 | internal void SetInfoBox(string p) 195 | { 196 | string text = p; 197 | SetInfoCallback d = new SetInfoCallback(add_text); 198 | this.Invoke(d, new Object[] { text }); 199 | } 200 | 201 | public void add_text(String _msg) 202 | { 203 | this.textBox_packetReport.Text += _msg; 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /assignment2_medell/View.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /assignment2_medell/assignment2_medell.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8ACCC9A5-180E-4CAF-8BE6-8C0BD63638FD} 8 | WinExe 9 | Properties 10 | assignment2_medell 11 | assignment2_medell 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Form 53 | 54 | 55 | View.cs 56 | 57 | 58 | 59 | 60 | ResXFileCodeGenerator 61 | Resources.Designer.cs 62 | Designer 63 | 64 | 65 | True 66 | Resources.resx 67 | True 68 | 69 | 70 | View.cs 71 | 72 | 73 | SettingsSingleFileGenerator 74 | Settings.Designer.cs 75 | 76 | 77 | True 78 | Settings.settings 79 | True 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 105 | -------------------------------------------------------------------------------- /assignment2_medell/bin/Debug/assignment2_medell.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/bin/Debug/assignment2_medell.exe -------------------------------------------------------------------------------- /assignment2_medell/bin/Debug/assignment2_medell.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /assignment2_medell/bin/Debug/assignment2_medell.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/bin/Debug/assignment2_medell.pdb -------------------------------------------------------------------------------- /assignment2_medell/bin/Debug/assignment2_medell.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/bin/Debug/assignment2_medell.vshost.exe -------------------------------------------------------------------------------- /assignment2_medell/bin/Debug/assignment2_medell.vshost.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /assignment2_medell/bin/Debug/assignment2_medell.vshost.exe.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/assignment2_medell.Properties.Resources.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/assignment2_medell.Properties.Resources.resources -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/assignment2_medell.View.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/assignment2_medell.View.resources -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/assignment2_medell.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\bin\Debug\assignment2_medell.exe.config 2 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\bin\Debug\assignment2_medell.exe 3 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\bin\Debug\assignment2_medell.pdb 4 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\obj\Debug\assignment2_medell.csprojResolveAssemblyReference.cache 5 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\obj\Debug\assignment2_medell.Properties.Resources.resources 6 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\obj\Debug\assignment2_medell.View.resources 7 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\obj\Debug\assignment2_medell.csproj.GenerateResource.Cache 8 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\obj\Debug\assignment2_medell.exe 9 | C:\Users\max\Documents\School\3314\assignment2_medell\assignment2_medell\obj\Debug\assignment2_medell.pdb 10 | -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/assignment2_medell.csproj.GenerateResource.Cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/assignment2_medell.csproj.GenerateResource.Cache -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/assignment2_medell.csprojResolveAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/assignment2_medell.csprojResolveAssemblyReference.cache -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/assignment2_medell.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/assignment2_medell.exe -------------------------------------------------------------------------------- /assignment2_medell/obj/Debug/assignment2_medell.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxakuru/VideoClient/e9c0efb8d1a5ba07edf8203e17611830cf598490/assignment2_medell/obj/Debug/assignment2_medell.pdb --------------------------------------------------------------------------------