Problème Stream tcp (video/mp4) [Fermé]

Signaler
-
Bonjour, je voudrais créer un object Stream. Qui peut être modifié est aussi qui va envoie le flux Stream en tcp.

voilà mon scripte est en dessous !

le navigateur reçois bien les données. J'ai essayé en Content-Type Text/Text mais, (video /mp4) la lecture ne se fait pas !

pouvez-vous m'aider à comprendre ?


public delegate void EventSend(Stream stream);
public class MediaServeur
{
public event EventSend eventSend;

public MediaServeur(IPAddress IP, int Port)
{
ServeurTcp Serveur_tcp = new ServeurTcp(IP, Port, Received);
Thread newThread = new Thread(delegate()
{
while (true)
{
FluxSystem();
}
});
newThread.Start();
}

public void Received(Byte[] Data, Session send)
{
string DataString = Encoding.ASCII.GetString(Data, 0, Data.Length);
Console.WriteLine(DataString);

if (new Regex("^GET").IsMatch(DataString))
{
string GET = new Regex(@"^GET (.*)\s").Match(DataString).Groups[1].Value.Trim();
string[] GETDATA = GET.Split(new char[] { ' ' });
String Url = GETDATA[0];
Console.WriteLine("Media URL :" + Url);
if (Url == "/media")
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("Media Serveur Received");
Console.ResetColor();

Stream stream_sr = new MemoryStream();

send.send(Encoding.UTF8.GetBytes(MediaServeurHeader()));
eventSend += new EventSend(delegate(Stream stream)
{
if (stream_sr != stream)
{
send.send(((MemoryStream)stream).ToArray());
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("Send Stream");
Console.ResetColor();
stream_sr = stream;
}
});
}
}
}

private string MediaServeurHeader()
{
return string.Format("HTTP/1.1 {0}\r\n"
+ "Server: {1}\r\n"
+ "Content-Type: {2}\r\n"
+ "Accept-Ranges: {3}\r\n"
+ "\r\n",
200, "MediaServeur", "video/mp4", "bytes");
}//audio/mpeg


int NumberPackLength = 200;
List<Byte> newDATA_sr;

public List<Stream> streams = new List<Stream>();

public void FluxSystem()
{
if (streams.Count != 0)
{
try
{
foreach (Stream s in streams)
{
eventSend(s);
streams.Remove(s);
}
}
catch { }
}
}

public void decoup(Byte[] DataFile)
{
streams = new List<Stream>();
int Length = DataFile.Count();
Console.WriteLine(Length);
if (NumberPackLength < Length)
{
Console.WriteLine("On Decoupe");
int lengthMax = DataFile.Count() / NumberPackLength;
int lengthMaxCondition = (float)DataFile.Count() / NumberPackLength > DataFile.Count() / NumberPackLength ? 1 : 0;

if (lengthMaxCondition != 0)
{
lengthMax = lengthMax + 1;
}

int Index = 0;

for (int i = 0; i <= lengthMax; i++)
{
List<Byte> newDATA = new List<byte>();

for (int x = 0; x <= NumberPackLength; x++)
{
if (Index < Length)
{
newDATA.Add(DataFile[Index]);
}

Index++;
}

if (newDATA_sr != newDATA)
{
streams.Add(new MemoryStream(newDATA.ToArray()));
newDATA_sr = newDATA;
}
}
}
else
{
streams.Add(new MemoryStream(DataFile));
Console.WriteLine("Not Decoupe");
}
}