Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Sample speed test for Transport Stream construction

, 13 Apr 2004
A program that emulates the TS construction from ES files for the HDTV standard.
ts_constructor.zip
TS_constructor
TS_constructor.exe
ts_source_code.zip
TS_Source_Code
App.ico
ts.ico
mpeg_tst.csproj.user
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace mpeg_tst
{
	public class options : System.Windows.Forms.Form
	{
		private Sample father=new Sample();
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TrackBar PES_H_L;
		private System.Windows.Forms.TextBox set_HL;
		private System.Windows.Forms.TextBox set_PL;
		private System.Windows.Forms.TrackBar PES_P_L;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		public System.Windows.Forms.ComboBox carrier;
		private System.Windows.Forms.Button close;
		private System.ComponentModel.Container components = null;

		public options(Sample f)
		{
			InitializeComponent();
			father=f;
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				this.Hide();
				father.calc_space();
			}
		}

		#region Windows Form Designer generated code
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(options));
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.PES_H_L = new System.Windows.Forms.TrackBar();
			this.set_HL = new System.Windows.Forms.TextBox();
			this.set_PL = new System.Windows.Forms.TextBox();
			this.PES_P_L = new System.Windows.Forms.TrackBar();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.carrier = new System.Windows.Forms.ComboBox();
			this.close = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.PES_H_L)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.PES_P_L)).BeginInit();
			this.SuspendLayout();
			// 
			// textBox1
			// 
			this.textBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
			this.textBox1.Location = new System.Drawing.Point(8, 8);
			this.textBox1.Multiline = true;
			this.textBox1.Name = "textBox1";
			this.textBox1.ReadOnly = true;
			this.textBox1.Size = new System.Drawing.Size(656, 256);
			this.textBox1.TabIndex = 0;
			this.textBox1.TabStop = false;
			this.textBox1.Text = "This simulation doesn\'t include the ADAPTATION FIELD in TS packets. You can set P" +
				"ES packets length to some limits and PES_Header_Length also , but these settings" +
				" will apply to all PES packets ( audio style ) , every packet having the same le" +
				"ngth , not a variable one ( video style ). There\'s another setting to try : \" Ca" +
				"rrier\". It has two choices : \" File\" and \"Emulated Network\". \"File\" means that a" +
				"ll TS packets will be saved in \"result.ts\" file in your program directory , whil" +
				"e \"Emulated Network means that after generation each TS packet is discarded , on" +
				"ly the last one remaining in the \"result.ts\" file for you to see. Furthermore , " +
				"each generated ES is saved in your program directory under a name like \"ES_sampl" +
				"e_x.es\". Each ES consists of one character repeated for the entire file length s" +
				"o it\'s easy to identify ES components in the resulting TS. The characters in ES " +
				"files start with \"A\" , while the TS header consists of \"*\" signs.The same way , " +
				"the begining of a PES antet packet it\'s marked by 3 signs of \"#\" and the rest of" +
				" the antet is filled with \"$\" signs.The exceptions are PES_HEADER_LENGTH and PES" +
				"_PACKET_LENGTH that are left to their real values. So , it shall be easy to read" +
				" the TS file output. Another disadvantage compared to real multiplexing it\'s tha" +
				"t this program doesn\'t really construct the TS and PES packets , but just the he" +
				"aders. Then the TS packet it\'s formed by the concatenation ( stream writing ) of" +
				" TS header (4 bytes) , PES header ( variable length because the PES_HEADER_LENGT" +
				"H value ) and ES data.  This means that the aproximated speed it\'s higher than t" +
				"he one you\'ll get in real multiplexing by max. 30%. Also , using the \"File\" opti" +
				"on will generate a lower speed than \"Emulated Network\" because of the SEEK_POSIT" +
				"ION indicator in the output file ( and keep in mind that the TS output file can " +
				"be quite big ) while in the \"Emulated Network\" mode output file size is fixed ( " +
				"188 bytes ). Another performance setting might be the \"Buffer Length\" setting. T" +
				"his sets how many PES packets are kept in memory for each ES. A small value it\'s" +
				" a clear disadvantage while a big value might eat up a lot of RAM and some thing" +
				"s just can\'t work without enough RAM ( like Windows :> ). Overall , each setting" +
				" you are alowed to change in this program can change the final result of speed m" +
				"easurement , but the definitive impact belongs to your system\'s resources as wel" +
				"l as the speed of your HDD , RAM and CPU.";
			this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 302);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(112, 23);
			this.label1.TabIndex = 1;
			this.label1.Text = "PES Header Length :";
			// 
			// PES_H_L
			// 
			this.PES_H_L.LargeChange = 10;
			this.PES_H_L.Location = new System.Drawing.Point(112, 296);
			this.PES_H_L.Maximum = 255;
			this.PES_H_L.Name = "PES_H_L";
			this.PES_H_L.Size = new System.Drawing.Size(120, 45);
			this.PES_H_L.TabIndex = 2;
			this.PES_H_L.TickFrequency = 16;
			this.PES_H_L.ValueChanged += new System.EventHandler(this.act_HL1);
			// 
			// set_HL
			// 
			this.set_HL.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
			this.set_HL.Location = new System.Drawing.Point(144, 272);
			this.set_HL.MaxLength = 3;
			this.set_HL.Name = "set_HL";
			this.set_HL.Size = new System.Drawing.Size(56, 20);
			this.set_HL.TabIndex = 3;
			this.set_HL.Text = "0";
			this.set_HL.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			this.set_HL.TextChanged += new System.EventHandler(this.act_HL);
			// 
			// set_PL
			// 
			this.set_PL.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
			this.set_PL.Location = new System.Drawing.Point(384, 271);
			this.set_PL.MaxLength = 5;
			this.set_PL.Name = "set_PL";
			this.set_PL.Size = new System.Drawing.Size(56, 20);
			this.set_PL.TabIndex = 6;
			this.set_PL.Text = "4000";
			this.set_PL.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			this.set_PL.TextChanged += new System.EventHandler(this.act_PL);
			// 
			// PES_P_L
			// 
			this.PES_P_L.LargeChange = 10;
			this.PES_P_L.Location = new System.Drawing.Point(352, 295);
			this.PES_P_L.Maximum = 65535;
			this.PES_P_L.Minimum = 4;
			this.PES_P_L.Name = "PES_P_L";
			this.PES_P_L.Size = new System.Drawing.Size(120, 45);
			this.PES_P_L.TabIndex = 5;
			this.PES_P_L.TickFrequency = 5000;
			this.PES_P_L.Value = 4000;
			this.PES_P_L.ValueChanged += new System.EventHandler(this.act_PL1);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(248, 303);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(112, 23);
			this.label2.TabIndex = 4;
			this.label2.Text = "PES Packet Length :";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(496, 275);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(48, 23);
			this.label3.TabIndex = 7;
			this.label3.Text = "Carrier :";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(280, 320);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(64, 16);
			this.label4.TabIndex = 8;
			this.label4.Text = "( in bytes )";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(40, 320);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(64, 16);
			this.label5.TabIndex = 9;
			this.label5.Text = "( in bytes )";
			// 
			// carrier
			// 
			this.carrier.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(255)), ((System.Byte)(192)));
			this.carrier.Items.AddRange(new object[] {
														 "File",
														 "Emulated Network"});
			this.carrier.Location = new System.Drawing.Point(544, 272);
			this.carrier.Name = "carrier";
			this.carrier.Size = new System.Drawing.Size(120, 21);
			this.carrier.TabIndex = 10;
			this.carrier.TabStop = false;
			this.carrier.Text = "File";
			// 
			// close
			// 
			this.close.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
			this.close.Location = new System.Drawing.Point(568, 312);
			this.close.Name = "close";
			this.close.Size = new System.Drawing.Size(80, 24);
			this.close.TabIndex = 11;
			this.close.Text = "CLOSE";
			this.close.Click += new System.EventHandler(this.close_Click);
			// 
			// options
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
			this.ClientSize = new System.Drawing.Size(672, 342);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.close,
																		  this.carrier,
																		  this.label5,
																		  this.label4,
																		  this.label3,
																		  this.set_PL,
																		  this.PES_P_L,
																		  this.label2,
																		  this.set_HL,
																		  this.PES_H_L,
																		  this.label1,
																		  this.textBox1});
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximumSize = new System.Drawing.Size(680, 376);
			this.MinimumSize = new System.Drawing.Size(680, 376);
			this.Name = "options";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Set Transport Stream options";
			((System.ComponentModel.ISupportInitialize)(this.PES_H_L)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.PES_P_L)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void close_Click(object sender, System.EventArgs e)
		{
			this.Hide();
			father.calc_space();
		}

		public int corelate(int val)
		{
			if (val<PES_H_L.Value+4) val=PES_H_L.Value+4;
			return val;
		}


		public void act_HL(object sender, System.EventArgs e)
		{
		 int val;
			if (set_HL.Text.Length==0) val=0;
			else val=int.Parse(set_HL.Text);
			if (val>255) {val=255;set_HL.Text="255";}
			PES_H_L.Value=val;
			val=corelate(PES_P_L.Value);
			set_PL.Text=val.ToString();
			PES_P_L.Value=val;
		}


		public void act_HL1(object sender, System.EventArgs e)
		{
			int val;
			val=PES_H_L.Value;
			set_HL.Text=val.ToString();
			val=corelate(PES_P_L.Value);
			set_PL.Text=val.ToString();
			PES_P_L.Value=val;
		}

		public void act_PL(object sender, System.EventArgs e)
		{
			int val;
			if (set_PL.Text.Length==0) val=4;
			else val=int.Parse(set_PL.Text);
			if (val>65535) val=65535;
			else if(val<4) val=4;
			val=corelate(val);
			set_PL.Text=val.ToString();
			PES_P_L.Value=val;
		}

		public void act_PL1(object sender, System.EventArgs e)
		{
			int val;
			val=PES_P_L.Value;
			val=corelate(val);
			PES_P_L.Value=val;
			set_PL.Text=val.ToString();
		}

		public int get_HL()
		{return PES_H_L.Value;}

		public int get_PL()
		{return PES_P_L.Value;}

		public bool ret_carrier()
		{return (carrier.Text=="File");}
	
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

ro_angel_bv
Web Developer
Malaysia Malaysia
Dumitru Bogdan - alias Angel
 
Born 1980 , Brasov , Romania
 
Final year student at Transilvania University of Brasov , Faculty of Electrical Engineering & Computer Science , Department of Electronics & Computers
 
Programming : Visual C++ , Visual Fox Pro , Assembler & later , C#
 
Motto : "Nothing Last Forever" , and software is no exception

| Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 14 Apr 2004
Article Copyright 2004 by ro_angel_bv
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid